Skip to content

[Hackathon] setup key verification ignores TESTSPRITE_REQUEST_TIMEOUT_MS #470

Closed

Description

@luckyzd

Verified against (commit SHA or released version)

commit 988c035 (public main checked 2026-10-17; package v0.14.0), Node v22.23.2, macOS

Discord Username / User ID

luckyzd.

What does this improvement do?

testsprite setup --from-env does not apply TESTSPRITE_REQUEST_TIMEOUT_MS to its initial API-key verification request. The equivalent explicit --request-timeout option works. A user who sets a short environment deadline can therefore remain blocked in setup beyond that deadline.

Apply the existing shared timeout resolver when creating the verification client, preserving flag > environment > default precedence and the established clamping rules.

Details / implementation notes

Reproduction and results

Use TESTSPRITE_REQUEST_TIMEOUT_MS=1000 and a mocked fetch that waits until its AbortSignal is aborted. Call the setup key-verification handler runConfigure. A separate 1600 ms watchdog interrupts the environment-only case so the reproduction cannot hang:

Case Observed elapsed time Watchdog fired Result
Explicit requestTimeoutMs=1000 (control) 1003 ms no request timed out after 1s
Environment only, TESTSPRITE_REQUEST_TIMEOUT_MS=1000 1602 ms yes INTERRUPTED by the watchdog

Each case made exactly one mocked fetch and created no credentials file. The environment case was still pending after its configured deadline; the watchdog ended it. I did not wait out or measure the entire default timeout. This is an offline reproduction of setup's actual verification handler, not a live API test. Build passed.

Cause and proposed scope

setup's runInit path forwards options to runConfigure. The verification client passes only opts.requestTimeoutMs to HttpClient, bypassing resolveRequestTimeoutMs(opts, env), which handles the documented environment fallback for ordinary clients.

Use that resolver for the verification request without changing the verify-before-persist behavior. Add deterministic tests for environment-only deadline, explicit flag precedence, clamping/default behavior, and interrupted verification preserving credentials.

Related reports checked

PR #52 fixed forwarding the explicit option to setup verification; that fix is already present on this commit, and the explicit-option control passes. It did not resolve the environment variable at this direct HttpClient construction. #16 / PR #17 concern invalid flag parsing; #361 concerns clamping notices. #403 concerns request deadlines during retry backoff; this reproduction contains no retry/backoff at all.

This is an issue-first Season 4 hackathon submission. No fix PR is being opened yet; I will wait for maintainer acceptance and claim the issue before implementing it.

Self-contained offline reproduction

Save this as repro-b09.mjs, run npm run build in the repository, then run node repro-b09.mjs /path/to/testsprite-cli with Node 22. It uses dependency-injected fetch responses, a fake key, and temporary files; no external requests or paid runs.

import { resolve, join } from 'node:path';
import { pathToFileURL } from 'node:url';
import { mkdtemp, rm, access } from 'node:fs/promises';
import { tmpdir } from 'node:os';

// Dependency-injected mock fetch only: no sockets, external requests, or real keys.
const root = resolve(process.argv[2] ?? 'work/testsprite-cli');
const { runFailureGet } = await import(pathToFileURL(join(root, 'dist/commands/test.js')));
const { runConfigure } = await import(pathToFileURL(join(root, 'dist/commands/auth.js')));
const { ShutdownController } = await import(pathToFileURL(join(root, 'dist/lib/interrupt.js')));
const common = { profile: 'default', output: 'json', debug: false };
const env = { TESTSPRITE_API_KEY: 'sk-user-local-reproduction', TESTSPRITE_API_URL: 'https://mock.example.com', TESTSPRITE_REQUEST_TIMEOUT_MS: '1000' };
const dir = await mkdtemp(join(tmpdir(), 'testsprite-extra-repro-'));
try {
  for (const explicit of [true, false]) {
    const shutdown = new ShutdownController();
    let watchdogFired = false, fetches = 0;
    const watchdog = setTimeout(() => { watchdogFired = true; shutdown.interrupt('SIGINT'); }, 1600);
    const start = performance.now();
    try {
      await runConfigure({ ...common, fromEnv: true, ...(explicit ? { requestTimeoutMs: 1000 } : {}) }, {
        env, credentialsPath: join(dir, 'never-written'), shutdown, shutdownSignal: shutdown.signal,
        stdout: () => {}, stderr: () => {}, preludeWrite: () => {},
        fetchImpl: async (_url, init) => { fetches++; return new Promise((_resolve, reject) => { if (init.signal.aborted) reject(init.signal.reason); else init.signal.addEventListener('abort', () => reject(init.signal.reason), { once: true }); }); },
      });
    } catch (err) {
      console.log(JSON.stringify({ candidate: 'B09', source: explicit ? 'explicit option (control)' : 'environment only', configuredMs: 1000, elapsedMs: Math.round(performance.now() - start), credentialsCreated: await access(join(dir, 'never-written')).then(() => true, () => false), watchdogFired, fetches, code: err.code, errorName: err.constructor.name, message: err.message }));
    } finally { clearTimeout(watchdog); }
  }
} finally { await rm(dir, { recursive: true, force: true }); }

Confirmations

  • I have searched existing issues and this is not a duplicate.
  • I have provided my Discord identity above for reward coordination.

Activity

  1. added
    needs-triage
    hackathon
    on Oct 17, 2026
  2. fyZhang66 commented on Oct 20, 2026

    @fyZhang66
    Contributor

    Confirmed on v0.15.0, thanks @luckyzd. setup --from-env builds its key-verification client from the flag value only, so TESTSPRITE_REQUEST_TIMEOUT_MS is ignored and the 120 s default applies. Accepted, scope:

    • Use resolveRequestTimeoutMs (flag > env > default, same clamping) when creating that client.
    • Tests (must fail before the fix): the env var alone bounds the verification request; the flag still wins over the env var.

    No new dependency. Comment /assign to claim it.

  3. added
    accepted
    and removed
    needs-triage
    on Oct 20, 2026
  4. Herbicide7665 commented on Oct 21, 2026

    @Herbicide7665
    Contributor

    /assign

    Discord: weili_yang33

  5. added
    in-progress
    on Oct 21, 2026
  6. testsprite-hob commented on Oct 21, 2026

    @testsprite-hob

    Assigned to @Herbicide7665. Thanks for taking this on. (2 more slots available.)

    Your open assigned issues (1/3):
    (none)

  7. added a commit that references this issue on Nov 9, 2026
    6570c06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

acceptedhackathonin-progress

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions