Fix Unhandled Promise Rejection Crashes in Node.js (2026)
Node.js kills the whole process on an unhandled promise rejection since v15. Here's exactly how to find the leak and fix it for good in 2026.
By Babul Jack
An unhandled promise rejection in Node.js is a promise that rejects with no .catch(), no try/catch, and no second argument to .then() attached before the current microtask queue drains. Since Node.js 15, that is not a warning — it crashes your process with a non-zero exit code, taking every in-flight request down with it. Fixing it means finding the specific call site that dropped the rejection, not just adding a global handler.
I've debugged this exact crash in more client codebases than any other Node.js production issue — usually reported as "the API randomly restarts" long before anyone realizes a dropped promise is the cause. Here's the full diagnosis-to-fix workflow I use, with the version history and real numbers behind why this still catches teams off guard in 2026.
Why your Node.js process crashes on an unhandled promise rejection
Promises settle through the microtask queue, which Node drains completely between each macrotask (a timer, an I/O callback). When a promise rejects, the runtime can't immediately know whether a handler will be attached on a later tick, so it defers the decision. Only after the current microtask checkpoint finishes does Node check whether anything ever caught the rejection — and if nothing did, it fires process.emit('unhandledRejection', reason, promise).
What happens next depends entirely on your Node.js version, and this is the part that trips up developers who learned Node before 2020. Node's official process documentation describes the 'unhandledRejection' event, but the consequence of that event changed in a release that's easy to miss if you haven't touched the default flag.
The version change that matters
Before Node 15, an unhandled rejection printed UnhandledPromiseRejectionWarning and your app kept running — a cosmetic warning you could ignore for years. The default --unhandled-rejections CLI mode flipped from warn to throw starting in Node.js 15.0.0, and every actively supported release since — 22, 24 and 26 — keeps that default. In practice: the same bug that used to be a log line in 2019 now takes your service offline in 2026.
If you're running anything from Node 18 through the current Node 26 release without touching CLI flags, an unhandled rejection crashes the process by default, full stop.
How to reproduce it (so you can see the real crash shape)
The fastest way to recognize this bug in your own logs is to trigger it once in isolation:
// repro.js — plain CommonJS, Node 18/20/22/24/26
function getUser(id) {
return new Promise((resolve, reject) => {
if (id !== 1) return reject(new Error(`user ${id} not found`));
resolve({ id, name: 'Ada' });
});
}
getUser(2).then((user) => console.log(user.name));
console.log('main continues...');
Run node repro.js and you'll see main continues... print first — the rejection happens asynchronously — then Node throws the error trace and exits with code 1. It looks exactly like a synchronous throw, except the stack bottoms out in the module loader instead of a catch block, because there never was one.
The forEach trap
This is the single most common real-world shape of the bug, and it looks nothing like a raw .then() chain:
const ids = [1, 2, 3];
async function getUser(id) {
if (id !== 1) throw new Error(`user ${id} not found`);
return { id, name: 'Ada' };
}
async function main() {
ids.forEach(async (id) => {
const user = await getUser(id); // forEach ignores the returned promise
console.log(user.name);
});
}
main();
Array.prototype.forEach never awaits its callback's return value, so the promise that the async wrapper produces for id=2 rejects into the void. Swap forEach for a for...of loop with await inside it, or Promise.all(ids.map(...)), and the rejection becomes catchable again.
How to fix an unhandled promise rejection in Node.js
1. Find the real call site, not the symptom
Read the rejection reason before you touch any code. If it's a proper Error object with a stack trace, that stack points at the real source. If it's a bare string or plain object, someone rejected with reject('failed') instead of reject(new Error('failed')) — fix that first so future crashes are debuggable.
A try/catch only protects an awaited call. Wrapping an un-awaited async call in try/catch catches nothing — the function has already returned by the time the rejection happens.
3. Finish every .then() chain with .catch()
If you still have raw promise chains in the codebase, every one needs a terminal .catch(). An orphaned .then() with no second argument and no trailing .catch() is a guaranteed future crash.
4. Replace forEach with a loop or Promise.all/allSettled
// Sequential, stops on first failure
for (const id of ids) {
await getUser(id);
}
// Parallel, all must succeed
await Promise.all(ids.map(getUser));
// Parallel, continue on partial failure
const results = await Promise.allSettled(ids.map(getUser));
Promise.allSettled() is the right choice whenever one failed lookup shouldn't take down the other two — I use it by default for any batch of independent API calls in client projects now.
5. Wrap async Express route handlers
Express does not natively await async handlers, so a rejected promise inside one disappears silently unless you forward it:
Fastify avoids this entirely — it natively awaits async handlers, so teams building a new service where Express compatibility isn't a hard requirement increasingly pick it for exactly this reason.
This should log and exit, not swallow the error and keep running. process.on('uncaughtException', ...) does not catch unhandled rejections — they're a separate event with a separate default action, so you need both handlers if you want full coverage, and neither should try to resume normal operation.
Is this really the most common Node.js production error?
For many teams, yes. In a 2026 analysis of 120 production Node.js teams, incidents traced to error-handling gaps accounted for 41% of all severity-1 outages — more than database issues and deployment failures combined — and unhandled promise rejections alone were the single largest category, at roughly 28% of all production incidents. That one statistic is why I treat this as a checklist item on every code review for client Node.js services, not an edge case worth skipping.
Comparing the three Node.js error channels
Error type
How it propagates
Default behavior
Synchronous throw
Bubbles up the call stack
Caught by any enclosing try/catch
Unhandled promise rejection
Fires async after the microtask queue drains
Crashes the process (Node 15+)
EventEmitter error with no listener
Thrown synchronously from .emit('error')
Crashes the process immediately, no catch point
How do I prevent this long-term instead of firefighting it?
Turn on @typescript-eslint/no-floating-promises and no-misused-promises as CI-blocking errors, not warnings — they catch a floating promise at the call site before it ships.
Run a CI job with NODE_OPTIONS=--unhandled-rejections=strict so your test suite fails loudly on any rejection it triggers but doesn't handle.
Track unhandledRejection volume in your APM (Sentry, Datadog) the same way you already track uncaught exceptions — a rising rate is a leading indicator of a crash-looping process.
Never swallow a rejection with an empty catch {}. If you must ignore one, log it at debug level and say why in a comment — a silent catch just turns a visible crash into silent data loss.
Write at least one test per async boundary that forces a rejection and asserts your code actually catches it.
If your team keeps hitting this class of bug across services, it's usually a sign the error-handling layer needs a proper audit rather than another patch — that's the kind of hardening work I do as part of web app development engagements, alongside the database and API layers most of these crashes trace back to. The same discipline applies whether the dropped rejection sits in an Express route or in the serverless connection pooling issues I've covered before.
Frequently asked questions
Does UnhandledPromiseRejectionWarning still just print a warning in Node.js?
No, not by default. That message only appears if you explicitly run with --unhandled-rejections=warn. On every actively supported Node.js release today, the default mode is throw, which means the same condition crashes the process instead of logging a warning.
Why does my try/catch not catch the rejection?
A try/catch only protects code it actually executes, which means it only catches a rejection if the call is awaited inside the try block. If you call an async function without await and without a .catch(), the try/catch has already finished executing by the time the promise rejects.
Does process.on('uncaughtException') also catch unhandled promise rejections?
No. They are two distinct events with two distinct default behaviors. You need a separate process.on('unhandledRejection', ...) listener, and it should be treated purely as a logging safety net rather than your primary error-handling strategy.
Can this happen in the browser too, not just Node.js?
Yes, but the consequence is different. Browsers fire a cancelable unhandledrejection event on window and log Uncaught (in promise) ... to the console — there's no process to crash, so the tab keeps running. The root cause (a rejected promise with nothing attached) is identical to the Node.js case.
What's the single highest-leverage fix for this in an existing codebase?
Enabling @typescript-eslint/no-floating-promises as a CI-blocking error. It finds every promise-returning expression used as a statement across the whole codebase in one pass, which catches the vast majority of real-world cases, including the classic forEach trap, without having to manually audit every async function.
Key takeaways
Since Node.js 15, an unhandled promise rejection crashes the process by default — it is not a cosmetic warning anymore.
Array.prototype.forEach with an async callback is the most common way developers accidentally produce an unhandled rejection from code that looks correct.
process.on('uncaughtException', ...) does not catch unhandled rejections; they're a separate event requiring their own listener.
Fix it at the call site first: pair every await with try/catch, finish every .then() with .catch(), and use Promise.all/allSettled instead of forEach for batches.
Unhandled promise rejections account for roughly 28% of production Node.js incidents in 2026, making this one of the highest-value checks to automate in CI rather than catch after a 3 a.m. page.