Public: anyone can read this; the crew can change it.
A test fails when any fetch in src has no timeout, and names it #14730
Check · Review · Land · Live done — Landed and live in production.
Every fetch( in src that runs on the server now has a timeout, and test/fetch-timeout.test.ts fails if a new one is added without one. The failure lists each call as file:line followed by the call's text. The test.
shipped production is serving it deploy 4ec2c16
2 earlier comments · 1 event
Every fetch( in src that runs on the server now has a timeout, and test/fetch-timeout.test.ts fails if a new one is added without one. The failure lists each call as file:line followed by the call's text.
The test. It reads src/*/.ts as plain text. For each call to the global fetch(, it reads up to the matching ) and checks for the word signal. It does not count obj.fetch(, names like doFetch(, comments, function fetch( declarations, or fetch(?: inside a regular expression; its first case checks all of these. Two things are not scanned, each with its reason in the test: src/web/ and src/apps/toolbar.ts, because that code runs in the visitor's browser. There is one allowed call, discover.ts's fetch(target, init): its init, built a few lines above, already has AbortSignal.timeout. Allowed calls are matched by the call's text rather than its line number, so editing above one doesn't break the test. A third case fails if an allowed call no longer exists.
The fixes. The limit lives in one place, src/kernel/fetch_timeout.ts: FETCH_TIMEOUT_MS = 30_000, plus boundedSignal(signal), which returns the caller's own signal if there is one and otherwise a 30-second timeout. It is used in:
- Wrappers that pass the caller's options through:
actions/cloud.ts,actions/pinned.ts(two),cluster/jobs.ts,system/footing.ts,perf/github_traffic.ts,snapshot/probe.ts,git/hook-address.ts,origins/origin_fetch.ts, and both calls inkernel/outbound.ts. Callers that already set a signal keep it. - Direct calls that had none:
arcade/carts.tsandchaos/report.ts.
spawn/cell.ts forward is different. It streams an app's response back to a visitor, so a fixed timeout would cut off long-lived responses. It now passes request.signal instead: the forward ends when the visitor disconnects.
Worth a look.
- In
jobs.tsandfooting.ts, the Kubernetes API calls that brought no signal now stop after 30 seconds. The long wait for a job to finish is a polling loop with its own limit, so it is not affected. - Calls through
outboundFetchwithout their own signal now stop after 30 seconds; every caller today already sets one.
Checks run. bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. scripts/fast.ts said the diff was too broad to name tests, so I picked the files covering the touched modules: 550 pass, 0 fail. The 26 skips are the unix-socket and cell suites this sandbox cannot run; the forge's check runs them. I also added a file with a bare fetch( and saw the test name it.
Not done. The browser-side fetch( calls under src/web/ have no timeout.
Try it. Run bun test test/fetch-timeout.test.ts. Then add export const x = () => fetch("http://a/"); to any file in src/ and run it again: the test fails, naming that file, line 1 and the call.
🤖 Generated with Claude Code
Every fetch( in src/ now has a timeout, and test/fetch-timeout.test.ts keeps it that way. The test reads src/*/.ts as text. It fails, naming file:line and the call, for any fetch( that passes no signal and isn't on its allow list.
The calls it found now carry a signal:
- Wrappers use the caller's signal, or
AbortSignal.timeout(FETCH_TIMEOUT_MS). That constant is defined once, insrc/kernel/fetch_timeout.ts. - The cell's forward in
src/spawn/cell.tsstops when the visitor's own request is cancelled.
The edits are in src/actions, src/arcade, src/chaos, src/cluster, src/git, src/origins, src/perf, src/snapshot and src/system.
The last check failed on two gate rules, and both are now answered by lines in a commit message:
- Direction: this is a guard against hangs and goes ahead of the pipeline items (#14721).
- No door: the
src/actionsedits only add a timeout to fetches that already existed. Nothing new is shown or reachable, sosrc/tui/has nothing to add.
bun scripts/gate.ts, bun x tsc --noEmit and the fetch-timeout test (4 tests) pass locally. The gate still notes five files with comment lines over 100 columns. --fix changed nothing, and the note says the nightly rewrap handles them on main.
How to try it: run bun test test/fetch-timeout.test.ts. Then add a file in src/ with fetch("http://a/") and run it again; the failure names that file and line.
🤖 Generated with Claude Code
Approved. The scan test names file:line and the call, the limit lives in src/kernel/fetch_timeout.ts, and the wrappers keep a caller signal. This is a server-side guard with no page or terminal change, so the preview and the TUI door do not apply. Two things I would do next: (1) Add a header-wait timeout to spawn/cell.ts forward. It uses request.signal, so an app that never answers holds the visitor request open until they leave. That is the hang the issue targets. Use a long limit named in fetch_timeout.ts, and leave the body stream unbounded. (2) Replace the repeated inline wrapper lambdas with one boundedFetch(u, i) helper in fetch_timeout.ts. pinned.ts, probe.ts and footing.ts now have 150+ column lines. Tighten the scan too, because the word signal satisfies it even as signal: undefined: require signal: followed by a non-undefined value, or a call to boundedSignal.
Left #14721 open: 1 unticked item remain (Every offender found is fixed in the same pull with AbortSignal.timeout and a limit named in one place.).
Every
fetch(insrcthat runs on the server now has a timeout, andtest/fetch-timeout.test.tsfails if a new one is added without one. The failure lists each call asfile:linefollowed by the call's text.The test. It reads
src/*/.tsas plain text. For each call to the globalfetch(, it reads up to the matching)and checks for the wordsignal. It does not countobj.fetch(, names likedoFetch(, comments,function fetch(declarations, orfetch(?:inside a regular expression; its first case checks all of these. Two things are not scanned, each with its reason in the test:src/web/andsrc/apps/toolbar.ts, because that code runs in the visitor's browser. There is one allowed call,discover.ts'sfetch(target, init): itsinit, built a few lines above, already hasAbortSignal.timeout. Allowed calls are matched by the call's text rather than its line number, so editing above one doesn't break the test. A third case fails if an allowed call no longer exists.The fixes. The limit lives in one place,
src/kernel/fetch_timeout.ts:FETCH_TIMEOUT_MS = 30_000, plusboundedSignal(signal), which returns the caller's own signal if there is one and otherwise a 30-second timeout. It is used in:actions/cloud.ts,actions/pinned.ts(two),cluster/jobs.ts,system/footing.ts,perf/github_traffic.ts,snapshot/probe.ts,git/hook-address.ts,origins/origin_fetch.ts, and both calls inkernel/outbound.ts. Callers that already set a signal keep it.arcade/carts.tsandchaos/report.ts.spawn/cell.tsforwardis different. It streams an app's response back to a visitor, so a fixed timeout would cut off long-lived responses. It now passesrequest.signalinstead: the forward ends when the visitor disconnects.Worth a look.
jobs.tsandfooting.ts, the Kubernetes API calls that brought no signal now stop after 30 seconds. The long wait for a job to finish is a polling loop with its own limit, so it is not affected.outboundFetchwithout their own signal now stop after 30 seconds; every caller today already sets one.Checks run.
bun scripts/gate.ts --fixandbun x tsc --noEmitare clean.scripts/fast.tssaid the diff was too broad to name tests, so I picked the files covering the touched modules: 550 pass, 0 fail. The 26 skips are the unix-socket and cell suites this sandbox cannot run; the forge's check runs them. I also added a file with a barefetch(and saw the test name it.Not done. The browser-side
fetch(calls undersrc/web/have no timeout.Try it. Run
bun test test/fetch-timeout.test.ts. Then addexport const x = () => fetch("http://a/");to any file insrc/and run it again: the test fails, naming that file, line 1 and the call.🤖 Generated with Claude Code
Closes #14721