feat: allow configuring HTTP timeout via APIDRIFT_TIMEOUT_MS env var - #23
Open
vivekyadav-3 wants to merge 8 commits into
Open
feat: allow configuring HTTP timeout via APIDRIFT_TIMEOUT_MS env var#23vivekyadav-3 wants to merge 8 commits into
vivekyadav-3 wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a configurable HTTP request timeout for the CLI’s Axios fetch layer via APIDRIFT_TIMEOUT_MS, keeping the existing 10s default, and documents the new setting in the README.
Changes:
- Add
APIDRIFT_TIMEOUT_MSsupport infetchWithRetry()(default10000ms on unset/invalid). - Document environment variables and add troubleshooting guidance for request timeouts.
- Also adjusts snapshot listing order and improves
initmessaging when refusing to overwrite an existing config.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/core/fetcher.js | Introduces a timeout constant sourced from APIDRIFT_TIMEOUT_MS and uses it for Axios requests. |
| README.md | Documents env vars (including APIDRIFT_TIMEOUT_MS) and adds troubleshooting for timeout/auth token issues. |
| src/storage/snapshotStore.js | Sorts snapshot tags returned by listSnapshots() for deterministic output. |
| src/commands/init.js | Adds clearer console guidance when the user chooses not to overwrite an existing config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+10
to
+20
| /** | ||
| * HTTP request timeout in milliseconds. | ||
| * Override via the APIDRIFT_TIMEOUT_MS environment variable. | ||
| * Defaults to 10000 (10 seconds) if unset or if the value is not a positive integer. | ||
| */ | ||
| const DEFAULT_TIMEOUT_MS = 10000; | ||
| const TIMEOUT_MS = (() => { | ||
| const raw = process.env.APIDRIFT_TIMEOUT_MS; | ||
| if (!raw) return DEFAULT_TIMEOUT_MS; | ||
| const parsed = Number(raw); | ||
| return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_TIMEOUT_MS; |
Comment on lines
26
to
+30
| return fs | ||
| .readdirSync(SNAP_DIR) | ||
| .filter((f) => f.endsWith(".json")) | ||
| .map((f) => f.replace(".json", "")); | ||
| .map((f) => f.replace(".json", "")) | ||
| .sort(); |
| console.log(` ${chalk.gray("STAGING_TOKEN=your_token_here")}`); | ||
| console.log(` ${chalk.gray("PROD_TOKEN=your_token_here")}`); | ||
| console.log( | ||
| ` 2. Add ${chalk.cyan(".env")} to your ${chalk.cyan(".gitignore")} to keep tokens out of git` |
Author
|
Hi @tanmayjoddar, |
…ent-exit-on-no-overwrite
…rable-http-timeout-env-var
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #7
fetchWithRetry()had a hardcodedtimeout: 10000. Users hittingslow APIs had no way to increase it without editing source code.
Changes
src/core/fetcher.js: AddedTIMEOUT_MSconstant that readsAPIDRIFT_TIMEOUT_MSenv var, falling back to10000if unset or invalidREADME.md: Added Environment Variables table andTroubleshooting section
Usage