Error message

ERR_UNHANDLED_REJECTION in Node.js

A promise was rejected and nothing handled the rejection. Since Node.js 15, the default is to treat it as an uncaught exception: the process exits with code 1. The ERR_UNHANDLED_REJECTION code only appears when the rejection reason isn’t an Error. Installing the Sentry SDK changes the outcome: the process keeps running.

Updated

Examples run on 19 November 2026 with Node.js 24.21.0 and @sentry/node 9.47.2, 10.78.0 and 11.12.0. Errilo is in private beta.

What the message says

A promise rejected with something that isn’t an Error, here a string:

index.js
Promise.reject('timeout');

Node.js wraps the reason in an error of its own and exits with code 1:

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 "timeout".
    at throwUnhandledRejectionsMode (node:internal/process/promises:392:7)
    at processPromiseRejections (node:internal/process/promises:475:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:106:37) {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v24.21.0

When the reason is an Error, Node.js throws that error as it is: you see your message and your stack trace, with no ERR_UNHANDLED_REJECTION anywhere, and the process still exits with code 1.

index.js
async function loadUser() {
  throw new Error('user not found');
}
loadUser();

In both cases, a process.on('uncaughtException') listener receives the error with origin set to 'unhandledRejection'.

Node.js behavior and the --unhandled-rejections flag

The default mode has been throw since Node.js 15: the rejection is raised as an uncaught exception, unless an unhandledRejection listener is registered. That last point is the one that matters in production. The other modes, checked with Node.js 24.21.0:

Modes of --unhandled-rejections, observed with Node.js 24.21.0
ModeWithout a listenerWith an unhandledRejection listener
throw (default)Uncaught exception, exit code 1The listener is called, the process keeps running
strictUncaught exception, exit code 1Uncaught exception, exit code 1: the listener doesn’t prevent it
warnUnhandledPromiseRejectionWarning, the process keeps running, exit code 0—
warn-with-error-codeSame warning, the process keeps running, then exits with code 1—

Fixes

index.js
async function loadUser(id) {
  throw new Error(`user ${id} not found`);
}

// 1. Handle the rejection where the promise is created.
loadUser(42).catch((error) => {
  console.error('could not load user:', error.message);
});

// 2. Last resort: log, then stop the process so the supervisor restarts it.
process.on('unhandledRejection', (reason) => {
  console.error('unhandled rejection:', reason);
  process.exit(1);
});

What @sentry/node captures

The onUnhandledRejectionIntegration integration is enabled by default. It registers an unhandledRejection listener, and that changes Node.js’s behavior: in throw mode, a listener means no more crash. Its default mode is warn. What we observed with 9.47.2, 10.78.0 and 11.12.0:

To keep Node.js’s crash while reporting the error, switch the integration to strict. In our test, the event was sent at level fatal before the process exited with code 1:

instrument.mjs
import * as Sentry from '@sentry/node';

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  integrations: [Sentry.onUnhandledRejectionIntegration({ mode: 'strict' })],
});

See the Node.js guide for the rest of the setup.

How Errilo shows it

The issue is titled with the error type and message (Error: user not found), with an Unhandled badge on the stack trace and the level, Fatal in strict mode. The issue’s location is the top frame of your code (loadUser).

Errilo groups on the exception type and the stack trace frames, not on the message. Rejections with strings all have the same type (Error) and the same stack trace, generated inside the SDK: in our test, Promise.reject('timeout') and Promise.reject('ECONNRESET') landed in the same issue, whose location points into @sentry/node. Two Error objects thrown from different functions gave two issues. One more reason to reject with Error.

Early access

The private beta is open, by invitation, to a handful of teams running a JavaScript, TypeScript, PHP or Python app in production. Join the waitlist and we’ll write to invite you.