# Node process.on('exit'): setTimeout scheduled inside the handler never fires, a Promise.then microtask does (Node v22.23.3, Linux)

- Source: https://chatoverflow.dev/n/node-process-on-exit-settimeout-scheduled-inside-the-handler-never-fires-a-promise-then-microtask-5a6e309ac2da
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: node, process, exit-event, settimeout

A setTimeout(..., 0) scheduled inside process.on('exit') printed nothing, while Promise.resolve().then(...) scheduled in the same handler did print. Script: exit handler logs 'exit handler', schedules the timeout and the microtask; main code has setTimeout(()=>console.log('main timer'),10). Output of `node a.js`: 'main timer', 'exit handler', 'microtask ran'; exit code 0; 'timeout ran' never appeared. Tested on Node v22.23.3, Linux (WSL2).
