fetch-signal: report fetch() that nothing can stop #6
Loading…
Reference in a new issue
No description provided.
Delete branch "rules/fetch-signal"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
New rule
fetch-signal(warn inrecommended.json): afetch(...)with nosignalin its init.Without a signal nothing can stop the request. Browsers set no time limit and Node waits 5 minutes for headers, so a server that accepts the connection and never answers hangs everything that awaits it (a request handler, a queue worker, a spinner).
fetch(url)andfetch(url, init)whereurlis visibly a URL (a string or template,new URL(...), a binding typedstring/URLor set to one) and the init visibly has nosignal. That covers an object literal, aconstobject, and spreads of objects the checker can see.new Request(url)without a signal, passed tofetch, is reported too. Calls throughglobalThis.fetch,window.fetchandself.fetchcount.signalproperty, whether written in place or coming from a spread or aconstthat has one. Also accepted is anything the checker can't see into:init: RequestInitorrequest: Requestparameters,RequestInfo,fetch(event.request), function results, computed keys, and a local binding namedfetch.signalin scope (only when a binding namedsignalis visible) and Time out after 10 s (signal: AbortSignal.timeout(10_000)). The edit adds a new init, prepends to an existing literal, or spreads aconstinit into a new object.crates/safe_ts_core/src/fetch_signal.rs) next tolints.rs, run in the same place.The feature packs already map
fetch(feature-browser says it rejects withTypeError). This rule doesn't use them: it is about the request never finishing, not about it failing.Also in this PR
vue-async-racebug: it searched the watcher's source text forsignal/AbortController, comments included. A comment mentioning "signal" silenced it, and that includes// oxlint-disable-next-line safe-ts/fetch-signal. It now leaves comments out of that search (Rules::codein vue.rs). I found this because annotating thevue_sfcfixture with// expect: fetch-signalmadevue-async-racevanish on the next line.settleAll/firstOkexamples indocs/guide/std-helpers.mdfetched without a signal. They now take asignalparameter and pass it. The JSDoc examples inpackages/std/src/async.tsare updated to match. Twofetchcalls in thevue_sfcfixture are now annotated// expect: fetch-signal.examples/demo,examples/vue, the docs Vue demo components and the playground presets report exactly what they did before (diffed per file and location).Tests
crates/safe_ts_core/tests/fixtures/fetch_signal/main.ts: 8 reported cases and 13 accepted ones.tests/fixes.rscheck the fix titles and the exact text after applying each fix.mainat04a5576(head b13cae3). What had to change: only the conflicts in the rule lists (analyze.rsnow runsmegamorphic::checkand thenfetch_signal::check;fetch-signalsits next tono-accumulating-copyin the oxlint plugin andrecommended.json) and intests/fixes.rs, where main'simport-attributesfix test and the twofetch-signaltests are both kept. No rule code, fixtures or docs needed changes: the new rules on main (no-accumulating-copy, stable-shape's call-site check, the tighter Vue URL rules) don't fire on this PR's fixtures or doc examples, and #5's call-following doesn't change their diagnostics.cargo nextest run --workspace: 104 passed, 0 failed (the earlierfeaturesfailure was fixed on main by #23).npm run test:std: 130 passed, 0 failed.npm run test:vite: passed.npm run typecheck: passed.npm run test:docs: passed (docs typecheck, wasm build, VitePress build).safe-ts checkonexamples/demo(22 problems, the demo's intended ones) andexamples/vue(no problems): nofetch-signalreports.Left out / uncertain
fetchis checked. Wrappers (ky,axios, a project'shttp.get) are not, and neither are functions forwarding aRequestInitthey received; their callers aren't followed.new AbortController().signalthat is never aborted passes.vue-async-race, because that rule still counts anysignalin the code as cancellation. A timeout does not cancel the stale run. I've noted this but haven't changed that heuristic beyond the comment fix.🤖 Generated with Claude Code
4405e2c8bctob13cae3c59b13cae3c5910fcd161b5