fetch without a timeout
This is how the comment reads inline, under the flagged line.
Why it matters
fetch has no default timeout. A hung upstream holds the request, the connection and the user until something else gives up.
What to do
Pass signal: AbortSignal.timeout(ms).
Examples
const res = await fetch(url);
const res = await fetch(url, { signal: AbortSignal.timeout(10_000) });What it catches
It reads the shape of the code: functions, blocks, loops and calls. Languages: TypeScript and JavaScript. Scope: Shipped code only. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
const r = await fetch(url);
Left alone
const r = await fetch(url, { signal: AbortSignal.timeout(5000) });Research
Network calls with no timeout or abort signal. One slow upstream can hang a worker forever.
- Ruff rules
- AI code audit taxonomy
- skill: code-review
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"fetch-without-timeout"
],
"severity": {
"fetch-without-timeout": "medium"
}
}
}
fetchwithout asignalwaits as long as the server likes. PassAbortSignal.timeout(ms).