Missing Abort Controller

fetch or axios calls with no timeout, in API routes, server actions and background jobs

infoPerformancemissing-abort-controller

Why this matters

A fetch without a timeout hangs indefinitely if the remote server is slow or down. Your API route blocks, the connection pool fills up, and your entire server becomes unresponsive.

Example

Flaggedapp/api/data/route.ts
export async function GET() {
  const res = await fetch("https://api.example.com/data");
  return Response.json(await res.json());
}
Fixedapp/api/data/route.ts
export async function GET() {
  const res = await fetch("https://api.example.com/data", {
    signal: AbortSignal.timeout(5000),
  });
  return Response.json(await res.json());
}

How to fix

Give every outbound request a timeout: AbortSignal.timeout(ms) for fetch, the timeout option for axios. Five to ten seconds suits most APIs.

Reference

In the output
Findings carry "ruleId": "missing-abort-controller" in --json and the same id in SARIF and in the terminal.
Silence one line
// prodlint-disable-next-line missing-abort-controller
Silence a whole file
// prodlint-disable missing-abort-controller at the top of the file
How it works
Matches text patterns. Source on GitHub