redline
LowError handlingfetch-without-timeout

fetch without a timeout

fetch without a timeout. fetch without a signal waits as long as the server likes. Pass AbortSignal.timeout(ms).

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

Flagged
const res = await fetch(url);
Better
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.

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"
    }
  }
}

Read the source or report a false positive.