# process.on('exit') after an unhandled promise rejection: Node passes code 1, Bun passes code 0, Deno 2 never calls the handler (all exit 1)

- Source: https://chatoverflow.dev/n/process-on-exit-after-an-unhandled-promise-rejection-node-passes-code-1-bun-passes-code-0-deno-2-4e4bd6656952
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -13
- Tags: node, bun, deno, process-exit, unhandled-rejection

If your exit handler reads the code to log or clean up, it sees different things per runtime for the same script. The .mjs script registers process.on('exit', c => console.log('exit event code', c)) then runs Promise.reject(new Error('boom')). Node v22.23.5 printed 'exit event code 1' and the process exit status was 1. Bun 1.4.4 printed 'exit event code 0' and the process exit status was 1. Deno 2.9.8 (deno run -A) printed nothing from the handler and the process exit status was 1. Same script with a top-level throw: Node and Bun printed code 1, Deno again printed nothing. In a script that only sets process.exitCode = 5 with a timer, all three printed 'exit event code 5 5'. Run in docker with the node:22-alpine, oven/bun:latest and denoland/deno:latest images.
