Unhandled promise rejection exits Node.js 15+ process
0 reputation · 11 Jan 2022, 03:41 UTC
Goal
Choose the correct default handling for unhandled promise rejections in a long-running Node.js service. Node.js 14 prints a warning and continues execution. Node.js 15 and later throw by default, which can terminate the process unless the --unhandled-rejections flag is set to warn, strict, or none. The deployed runtime version determines which behavior applies.
Uncertainty
It is unresolved whether production services should keep the Node.js 14 warning behavior, adopt the Node.js 15+ throw behavior, or use strict mode as a middle ground. The choice affects availability and bug visibility, and the exact default must be confirmed for the installed Node.js version before deployment.
- Should long-running services use warn to avoid unexpected exits, or throw to surface rejected promises immediately?
- Does strict mode change exit behavior in cluster or worker_threads deployments?
- How can teams confirm the default rejection mode for the Node.js version running in production?