Skip to content

feat: allow configuring HTTP timeout via APIDRIFT_TIMEOUT_MS env var - #23

Open
vivekyadav-3 wants to merge 8 commits into
tanmayjoddar:mainfrom
vivekyadav-3:feat/configurable-http-timeout-env-var
Open

feat: allow configuring HTTP timeout via APIDRIFT_TIMEOUT_MS env var#23
vivekyadav-3 wants to merge 8 commits into
tanmayjoddar:mainfrom
vivekyadav-3:feat/configurable-http-timeout-env-var

Conversation

@vivekyadav-3

Copy link
Copy Markdown

Summary

Closes #7

fetchWithRetry() had a hardcoded timeout: 10000. Users hitting
slow APIs had no way to increase it without editing source code.

Changes

  • src/core/fetcher.js: Added TIMEOUT_MS constant that reads
    APIDRIFT_TIMEOUT_MS env var, falling back to 10000 if unset or invalid
  • README.md: Added Environment Variables table and
    Troubleshooting section

Usage

# Bash/Linux/macOS
export APIDRIFT_TIMEOUT_MS=30000

# PowerShell (Windows)
$env:APIDRIFT_TIMEOUT_MS = "30000"

Copilot AI review requested due to automatic review settings May 20, 2026 05:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_MS support in fetchWithRetry() (default 10000 ms on unset/invalid).
  • Document environment variables and add troubleshooting guidance for request timeouts.
  • Also adjusts snapshot listing order and improves init messaging 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 thread src/core/fetcher.js Outdated
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();
Comment thread src/commands/init.js Outdated
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`
@vivekyadav-3

Copy link
Copy Markdown
Author

Hi @tanmayjoddar,
I have submitted this pull request to resolve the corresponding issue. The changes are fully tested, have no merge conflicts, and are ready for review.
Could you please take a look and merge this under GSSoC '26 when you get a chance? Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dx: allow configuring HTTP timeout via env var

3 participants