Repository navigation
Description
Verified against (commit SHA or released version)
988c035 (v0.14.0)
Discord Username / User ID
luckyzd
What does this improvement do?
Keep the presigned PUT timeout active through error-response body reading in project docs upload. A storage/proxy response that sends HTTP 403 headers but stalls its body currently leaves the command waiting past --request-timeout, with no typed error. This blocks automated document onboarding even though the upload has already been refused.
Details / implementation notes
Verified behavior
- Commit:
988c0355bb05631e9c6c1785e443937ff2a88c0e, package0.14.0. - Node
v22.23.2, macOS arm64; built withnpm run build. - Reproduction uses a loopback facade and storage endpoint with a dummy API key. No live TestSprite account, S3 object, or billing is involved.
With --request-timeout 1:
| Local PUT response | Observed result |
|---|---|
| Stalls before response headers | Exit 7, REQUEST_TIMEOUT, 1,244 ms |
| Complete HTTP 403 + XML body | Exit 10, presigned_put_failed, 232 ms |
| HTTP 403 headers + partial XML, then body stalls | Still running at 4,507 ms; watchdog sends SIGKILL; no typed error |
Each case performs exactly the upload-URL POST and the PUT. The register POST is never sent. The 4.5-second value is the reproduction watchdog, not a CLI timeout.
Root cause
runDocsUpload, project.ts lines 1180–1233 arms the request timer and shutdown listener around await fetchImpl(...). Fetch resolves after response headers. Its finally clears the timer, removes the shutdown listener, and disarms the upload scope before this read:
if (!putResponse.ok) {
const snippet = (await putResponse.text().catch(() => '')).slice(0, 300);
throw presignedPutError(...);
}Thus the non-OK response body is consumed outside the request's abort/deadline scope. The 300-character slice also happens after the entire body has been buffered; it does not bound the read. The observed bug is the lost deadline; no out-of-memory incident is claimed.
Reproduce
After building the repository, save the script below as repro.mjs and run node repro.mjs ./dist/index.js:
import http from 'node:http';
import { spawn } from 'node:child_process';
import { mkdtemp, writeFile, rm } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { resolve, join } from 'node:path';
// Local endpoints and dummy credential only. No TestSprite account or S3 access.
const cli = resolve(process.argv[2] ?? './dist/index.js');
const dir = await mkdtemp(join(tmpdir(), 'testsprite-docs-repro-'));
const file = join(dir, 'openapi.json');
await writeFile(file, '{}');
try {
for (const mode of ['stall-headers', 'complete-403', 'stall-403-body']) {
const requests = [];
const server = http.createServer((req, res) => {
requests.push(`${req.method} ${req.url}`);
req.resume();
req.on('end', () => {
if (req.url.endsWith('/docs/upload-url')) {
res.writeHead(200, { 'content-type': 'application/json' });
res.end(JSON.stringify({ uploadUrl: `http://127.0.0.1:${server.address().port}/put`,
s3Key: 'local-repro/openapi.json', expiresInSeconds: 3600 }));
} else if (req.method === 'PUT') {
if (mode === 'stall-headers') return;
res.writeHead(403, { 'content-type': 'application/xml' });
res.write('<Error><Code>AccessDenied</Code>');
if (mode === 'complete-403') res.end('</Error>');
} else {
res.writeHead(500); res.end('Unexpected request');
}
});
});
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
const started = performance.now();
const child = spawn(process.execPath, [cli, '--endpoint-url',
`http://127.0.0.1:${server.address().port}/api/cli/v1`, '--request-timeout', '1',
'--output', 'json', 'project', 'docs', 'upload', file, '--project', 'proj_local'], {
env: { ...process.env, TESTSPRITE_API_KEY: 'sk-user-local-reproduction',
TESTSPRITE_NO_UPDATE_NOTIFIER: '1', TESTSPRITE_NO_TELEMETRY: '1',
NO_PROXY: '127.0.0.1', no_proxy: '127.0.0.1' },
stdio: ['ignore', 'pipe', 'pipe'],
});
let stdout = '', stderr = '', watchdogKilled = false;
child.stdout.on('data', chunk => stdout += chunk);
child.stderr.on('data', chunk => stderr += chunk);
const watchdog = setTimeout(() => { watchdogKilled = true; child.kill('SIGKILL'); }, 4500);
const outcome = await new Promise(resolve => child.on('close', (code, signal) => resolve({code, signal})));
clearTimeout(watchdog);
server.closeAllConnections();
await new Promise(resolve => server.close(resolve));
console.log(JSON.stringify({ mode, elapsedMs: Math.round(performance.now() - started),
...outcome, watchdogKilled, requests, stdout: stdout.trim(), stderr: stderr.trim() }, null, 2));
}
} finally {
await rm(dir, { recursive: true, force: true });
}Proposed scope and acceptance checks
- Keep body consumption inside the PUT timeout/shutdown scope, or use a bounded diagnostic reader that promptly cancels the remainder.
- Preserve typed timeout/interrupt errors; do not silently swallow aborts in the diagnostic
.catch(() => ''). - A stalled non-OK body must settle within the configured request deadline (or fail promptly with the already-known storage status), never wait for the body indefinitely.
- Complete error responses must retain the HTTP status, bounded diagnostic snippet, and step-2 recovery guidance.
- Never register after a failed PUT; preserve the successful upload path.
- Regression coverage should return a
Responseimmediately and then stall its body. Existingproject.docs.spec.tstimeout coverage stalls the fetch promise before headers, so it does not cover this case.
Duplicate check
Searched existing issues and PRs for upload, presigned, response body, and docs timeout. #59 concerns failure-bundle downloads; #83 concerns JSON/history buffering. My #403 concerns caller abort signals during HttpClient retry sleeps. This defect is in the separate raw-fetch document-upload leg, with no retries or polling involved; fixing #403 would not fix it.
Discord: luckyzd. I will follow issue-first triage and wait for acceptance/assignment before submitting a fix PR.
Confirmations
- I have searched existing issues and this is not a duplicate.
- I have provided my Discord identity above for reward coordination.
Activity
fyZhang66 commentedon Oct 20, 2026
Confirmed from your repro, thanks @luckyzd.
runDocsUploadclears the timer and the shutdown scope infinallyas soon asfetchresolves on headers, so reading a failed PUT's body happens with no deadline. Accepted, scope:REQUEST_TIMEOUT(exit 7) within--request-timeout.We'll review #409 against this. No new dependency.
Herbicide7665 commentedon Oct 21, 2026
/assign
Discord: weili_yang33
testsprite-hob commentedon Oct 21, 2026
Assigned to @Herbicide7665. Thanks for taking this on. (0 more slots available.)
Your open assigned issues (3/3):
Herbicide7665 commentedon Oct 21, 2026
Yielding — I hadn't noticed #409 (opened pre-acceptance) already covers the accepted scope, and @luckyzd should keep it. Please feel free to unassign me.
Herbicide7665 commentedon Oct 21, 2026
@fyZhang66 could you unassign me from #515 and #404? Both have pre-acceptance PRs (#521 / #409) from their reporters, and with the slots freed I'd like to pick up #463 (accepted, currently unassigned) — it's a Windows PowerShell/encoding issue and Windows is my daily environment.
Herbicide7665 commentedon Oct 22, 2026
/unassign
testsprite-hob commentedon Oct 22, 2026
Unassigned @Herbicide7665. Thanks for the update — freeing this up for someone else.
OkeyAmy commentedon Nov 3, 2026
/assign
testsprite-hob commentedon Nov 3, 2026
Assigned to @OkeyAmy. Thanks for taking this on. (0 more slots available.)
Your open assigned issues (3/3):
testsprite-hob commentedon Nov 4, 2026
@OkeyAmy, your claim on this issue expires in about 24 hours unless you open a PR that links it (for example,
Closes #404orPart of #404). You can re-claim later with/assignif the issue is still free.fix(project): keep docs upload deadline through failed PUT body (Test…