Repository navigation
Description
Verified against (commit SHA or released version)
988c0355bb05631e9c6c1785e443937ff2a88c0e (current public main, built locally).
Discord Username / User ID
jerry_nee (display name: JerryNee)
What does this improvement do?
Apply the configured --request-timeout to presigned code and evidence downloads, including response-body consumption.
The metadata API request respects the timeout, but the subsequent download uses only the process shutdown signal. A stalled download can therefore keep test code get or test failure get --out pending beyond the requested deadline. This matters when collecting failure evidence in unattended CI.
With requestTimeoutMs: 1000, I reproduced both a stalled response header and a stalled HTTP 200 body in both command paths. All four downloads were still pending after 1300 ms, with their signals not aborted. Releasing each mock let the command finish. As a control, a stalled metadata request with the same configuration aborted with RequestTimeoutError after about 1004 ms.
These are local, injected-fetch reproductions of the built commands, not reports of a production service outage. No real credentials or cloud tests are needed.
Details / implementation notes
Code paths:
test.ts,streamPresignedBody/readPresignedBodypasses onlyshutdown.signalto the presigned fetch.bundle.ts,streamUrlToFileTrackedlikewise has no request deadline around fetch or body consumption. Its bounded retry count cannot help while an attempt remains pending.DOCUMENTATION.mddescribes the flag as a per-request wall-clock timeout. Presigned URL expiry does not bound an already-running download.
Reproduce: build the repository with npm ci and npm run build, save the following as repro-download-timeout.mjs in the repository root, then run node repro-download-timeout.mjs. It exercises both command paths and the API-request control, and removes its temporary bundle directories.
Standalone reproduction (mock network only)
import assert from 'node:assert/strict';
import { mkdtemp, rm } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { setTimeout as delay } from 'node:timers/promises';
import { runCodeGet, runFailureGet } from './dist/commands/test.js';
import { findSample } from './dist/lib/dry-run/samples.js';
globalThis.fetch = async () => { throw new Error('No network allowed'); };
const api = 'https://mock.invalid';
const artifact = 'https://artifact.invalid/repro.py';
const options = {
testId: 'test_repro', profile: 'default', output: 'text', dryRun: false,
debug: false, verbose: false, requestTimeoutMs: 1000,
};
const deps = {
env: { TESTSPRITE_API_KEY: 'sk-user-dummy', TESTSPRITE_API_URL: api },
credentialsPath: '/nonexistent/testsprite-repro/credentials',
stdout: () => {}, stderr: () => {}, rawStdout: () => {},
};
async function checkDownload(command, phase) {
const dir = await mkdtemp(join(tmpdir(), 'testsprite-timeout-repro-'));
let release;
let artifactSignal;
let markStarted;
let settled = false;
const started = new Promise(resolve => { markStarted = resolve; });
const context = structuredClone(findSample('GET', '/api/cli/v1/tests/test_repro/failure').body());
context.steps = [];
context.failure.evidence = [];
context.result.videoUrl = artifact;
context.result.failureAnalysisUrl = null;
const fetchImpl = async (url, init) => {
if (String(url).startsWith(api)) {
return Response.json(command === 'code' ? {
testId: 'test_repro', language: 'python', framework: 'pytest',
code: artifact, codeVersion: 'v1', etag: 'repro',
} : context);
}
assert.equal(String(url), artifact);
artifactSignal = init.signal;
if (phase === 'headers') {
return new Promise((resolve, reject) => {
release = () => resolve(new Response('print(1)\n'));
artifactSignal.addEventListener('abort', () => reject(artifactSignal.reason), { once: true });
markStarted();
});
}
const body = new ReadableStream({
start(controller) {
controller.enqueue(new TextEncoder().encode('print(1)\n'));
release = () => controller.close();
artifactSignal.addEventListener('abort', () => controller.error(artifactSignal.reason), { once: true });
},
});
markStarted();
return new Response(body);
};
const pending = (command === 'code'
? runCodeGet(options, { ...deps, fetchImpl })
: runFailureGet({ ...options, output: 'json', out: dir, failedOnly: false }, { ...deps, fetchImpl })
).then(() => { settled = true; }, error => { settled = true; throw error; });
try {
await started;
await delay(1300);
const observation = {
command, phase, configuredRequestTimeoutMs: 1000,
elapsedAfterDownloadStartedMs: 1300,
stillPending: !settled, downloadSignalAborted: artifactSignal.aborted,
};
console.log(JSON.stringify(observation));
assert.equal(settled, false);
assert.equal(artifactSignal.aborted, false);
} finally {
release();
await pending;
await rm(dir, { recursive: true, force: true });
}
}
for (const command of ['code', 'bundle']) {
for (const phase of ['headers', 'body']) await checkDownload(command, phase);
}
let controlSignal;
const start = Date.now();
const keepAlive = setInterval(() => {}, 1000);
try {
await assert.rejects(runCodeGet(options, {
...deps,
fetchImpl: async (_url, init) => new Promise((_resolve, reject) => {
controlSignal = init.signal;
init.signal.addEventListener('abort', () => reject(init.signal.reason), { once: true });
}),
}), error => error.name === 'RequestTimeoutError');
} finally {
clearInterval(keepAlive);
}
assert.equal(controlSignal.aborted, true);
console.log(JSON.stringify({ scenario: 'API request control', aborted: true, elapsedMs: Date.now() - start }));Proposed scope, subject to triage: thread the existing resolved flag/environment timeout into both download paths; keep it active through body consumption; compose it with shutdown cancellation; preserve bounded retries, partial-file cleanup, and the existing error contract. Add regression coverage for headers, body stalls, successful downloads and interruption. No new runtime dependency should be needed. test run artifact get shares the bundle path and should also receive regression coverage; I have not separately executed that command in this reproduction.
I searched existing issues and PRs. #404 concerns document upload error-body handling; #470 concerns setup key verification; #430 concerns output-stream errors/backpressure. This report concerns the separate presigned download paths.
I would like to work on this after acceptance and assignment. Submitted via GitHub CLI using the Hackathon Improvement fields; please add hackathon and needs-triage if they are not applied. AI assistance: Codex helped inspect the code, create and run the local reproductions, and draft this report. No fix PR has been started.
Confirmations
- I have searched existing issues and this is not a duplicate.
- I have provided my Discord identity above for reward coordination.
Activity
zeshi-du commentedon Oct 20, 2026
Thanks @JerryNee. Confirmed on v0.15.0: presigned code and evidence downloads don't honour
--request-timeout, so a stalled download can hang. The plan is a limit on first-byte wait and on stalls between chunks, not on total time, so large healthy downloads still finish.We'll fix this ourselves in an internal rework of how the CLI downloads and writes files, together with #425, #430, #487 and #501, so we won't take an external PR. Tracked internally as DEV-2179. This issue stays open until the fix ships.
zeshi-du commentedon Nov 24, 2026
We're fixing this internally: evidence downloads from
result get --outwill time out when a link stalls, without capping large downloads that are still making progress. It will ship in an upcoming release, so I'm closing this issue. Thanks @JerryNee for the report.