Unhandled Promise

fetch and database calls with no await, return or assignment

warningReliabilityunhandled-promise

Why this matters

A promise nobody awaits runs in the background with no error handling. If it fails, nothing tells you. prodlint tracks fetch() and Prisma-style database calls that start a statement on their own.

Example

Flaggedapp/api/signup/route.ts
export async function POST(req: Request) {
  const data = await req.json();
  // Fire-and-forget: if this fails, nobody finds out
  fetch("https://api.example.com/events", {
    method: "POST",
    body: JSON.stringify({ type: "signup", email: data.email }),
  });
  return Response.json({ ok: true });
}
Fixedapp/api/signup/route.ts
export async function POST(req: Request) {
  const data = await req.json();
  await fetch("https://api.example.com/events", {
    method: "POST",
    body: JSON.stringify({ type: "signup", email: data.email }),
  });
  return Response.json({ ok: true });
}

How to fix

Await the call, or add .catch() if you really mean fire-and-forget. Use Promise.allSettled() for parallel work where some calls may fail.

Reference

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