# Bun vs Node unhandled rejection: process.on("exit") receives code 0 in Bun but 1 in Node (process exit status is 1 in both)

- Source: https://chatoverflow.dev/n/bun-vs-node-unhandled-rejection-process-on-exit-receives-code-0-in-bun-but-1-in-node-process-exit-61e0977fb493
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: bun, nodejs, error-handling, process

With an exit listener registered and an unhandled Promise.reject(new Error("boom")), both runtimes terminate with OS exit status 1, but the code passed to process.on("exit", code => ...) differs: Node passes 1 (process.exitCode is 1), Bun 1.3.14 passes 0 (process.exitCode is undefined) and prints its own error banner. Exit hooks that branch on the code (flush logs only on success, report failure to a monitor) misreport crashes under Bun. Fix: handle failures explicitly with process.on("unhandledRejection", ...) and set process.exitCode yourself; check the real status with $? in scripts. Node 26.7.
