[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "...".]

Node.js · updated 2026-11-05

Printed right before the process exits with code 1, often well after startup when a background promise fails. Since Node 15 the default --unhandled-rejections mode is throw. Node prints this wrapper when the rejection reason is not an Error; Error reasons crash with their own stack instead.

node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "Request timed out".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v22.11.0

Quick fix

Find the promise that rejected and handle it: await it inside try/catch, or chain .catch() on promises you start without awaiting. The quoted reason is whatever was passed to reject() or thrown; because it is a string rather than an Error, there is no stack trace, so search your code for that text.

  1. Search the codebase and dependencies for the quoted reason text.
  2. Make sure every async call there is awaited or has a .catch() attached.
  3. Reject with new Error('...') instead of strings so future failures carry a stack.
  4. Give fire-and-forget calls their own .catch() that logs the failure.
  5. Add a process.on('unhandledRejection') handler that logs, reports and exits.
typescript
// Fire-and-forget work needs its own catch
void sendWelcomeEmail(user).catch((err) => {
  console.error('welcome email failed', err);
});

// Last-resort reporter. Adding this listener replaces Node's default crash,
// so exit explicitly and let the process manager restart the app.
process.on('unhandledRejection', (reason) => {
  console.error('Unhandled rejection:', reason);
  process.exit(1);
});
Fix it with your coding agent

Paste this into Claude Code, Cursor or Codex in the project that throws it. The agent reads this guide in plain text and applies the fix that matches your stack.

prompttext
Read https://runheed.com/errors/unhandled-promise-rejection.md and fix this error in this project.

Why it happens

Async call inside try without await

try { saveUser(u) } catch {} looks safe, but saveUser returns a pending promise and the try block finishes immediately. When the promise rejects later, the catch is long gone and nothing handles it.

Fire-and-forget background work

Analytics calls, cache warmers, webhook deliveries and setInterval jobs started from a request handler without .catch(). The first time the remote service fails, the rejection has no handler and the whole process exits.

Rejecting with a string or plain object

reject('timeout') or throw { status: 500 } gives Node nothing with a stack. You get this generic wrapper with only the reason text, which is why the crash looks impossible to locate.

Promise created early, awaited late

const a = loadA(); const b = loadB(); await a; await b; If b rejects while the code is still waiting on a, the rejection is unhandled at that moment and Node crashes before the await b line runs. Use Promise.all instead.

Async callbacks passed to APIs that ignore promises

array.forEach(async (x) => ...), EventEmitter listeners and older callback-style libraries discard the returned promise. A throw inside the async callback cannot reach the surrounding try/catch.

Other fixes

  • Use Promise.allSettled when parallel tasks may fail independently and you want every result.
  • Replace array.forEach(async ...) with for...of plus await, or await Promise.all(array.map(...)).
  • Turn on the @typescript-eslint/no-floating-promises rule to catch un-awaited promises in review.
  • As a temporary measure only, --unhandled-rejections=warn keeps the process up while you find the source.

Same error, other wording

  • UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
  • DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  • [UnhandledPromiseRejection: ...] { code: 'ERR_UNHANDLED_REJECTION' }

Let your coding agent catch the next one

Runheed records this error in production with the stack trace, the breadcrumbs before it and, when you set it, the agent session that shipped the code, and serves it to Claude Code, Cursor or any MCP client. With it connected, you can ask:

> Find the unhandled promise rejections in production, locate the code that rejects with that reason string, add the missing await or .catch(), and change the rejection to a real Error so it carries a stack.

Setup for Node.js and Express, Supabase Edge Functions or Fastify, then have your agent fix and resolve it.

Related errors

More in Memory, async and the process

Other error topics

Free tools: Source map stack trace decoder · Uptime and SLA downtime calculator · Error budget calculator · Stack trace formatter · JSON log viewer · HTTP status code reference.

References: Node.js process: 'unhandledRejection' event, Node.js CLI: --unhandled-rejections, MDN: Promise

Spotted a mistake? Email hello@greatwork.company. About Runheed.