[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.0Quick 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.
- Search the codebase and dependencies for the quoted reason text.
- Make sure every async call there is awaited or has a .catch() attached.
- Reject with new Error('...') instead of strings so future failures carry a stack.
- Give fire-and-forget calls their own .catch() that logs the failure.
- Add a process.on('unhandledRejection') handler that logs, reports and exits.
// 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);
});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.
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
- TypeError: Cannot read properties of undefined (reading 'x')
- TypeError: fetch failed
- Error: connect ECONNREFUSED 127.0.0.1:5432
More in Memory, async and the process
- FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memoryNode.js
- RangeError: Maximum call stack size exceededNode.js
- RecursionError: maximum recursion depth exceededPython
- RuntimeError: Event loop is closedPython
- RuntimeWarning: coroutine 'fetch_user' was never awaitedPython
- Error: listen EADDRINUSE: address already in use :::3000Node.js
- OSError: [Errno 98] Address already in usePython
- Error: error:0308010C:digital envelope routines::unsupportedNode.js
- MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error...Node.js
- Error: ENOENT: no such file or directory, open '/app/config.json'Node.js
- Error: EACCES: permission denied, open '/app/data/cache.json'Node.js
- Error: EMFILE: too many open files, open '/app/uploads/0412.jpg'Node.js
- PermissionError: [Errno 13] Permission denied: '/app/data/report.csv'Python
- CredentialsProviderError: Could not load credentials from any providersNode.js
- botocore.exceptions.NoCredentialsError: Unable to locate credentialsPython
- django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.Python
Other error topics
- FunctionsHttpError: Edge Function returned a non-2xx status codeNetwork and HTTP
- 422 Unprocessable Entity: {"detail":[{"type":"missing","loc":["body","email"],"msg":"Field...Network and HTTP
- Error: self-signed certificate in certificate chainNetwork and HTTP
- MongoServerError: E11000 duplicate key error collection: app.users index: email_1 dup...Databases
- psycopg.errors.UndefinedColumn: column "titel" does not existDatabases
- sqlite3.OperationalError: database is lockedDatabases
- Module not found: Can't resolve 'fs'Imports and modules
- AttributeError: module 'requests' has no attribute 'get'Imports and modules
- TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /app/src/index.tsImports and modules
- Error: NEXT_REDIRECTReact and Next.js rendering
- Objects are not valid as a React child (found: object with keys {id, name, total}). If...React and Next.js rendering
- Dynamic server usage: Route /x couldn't be rendered statically because it used `headers`.React and Next.js rendering
- UnboundLocalError: cannot access local variable 'total' where it is not associated with a...Undefined, None and type errors
- System.NullReferenceException: Object reference not set to an instance of an object.Undefined, None and type errors
- TypeError: 'NoneType' object is not iterableUndefined, None and type errors
- UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byteJSON, parsing and validation
- TypeError: Converting circular structure to JSONJSON, parsing and validation
- json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)JSON, parsing and validation
- Bad Request: Unsupported protocol version: 2026-07-28MCP servers and clients
- MCP error -32602: Input validation error: Invalid arguments for tool get_orderMCP servers and clients
- Not Acceptable: Client must accept both application/json and text/event-streamMCP servers and clients
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.