A Node.js module that forces unhandled promise rejections to crash the process immediately instead of failing silently.
hard-rejection is a Node.js module that makes unhandled promise rejections fail hard by immediately crashing the process with an error message. It solves the problem of silent promise failures, which can lead to hidden bugs in applications, by enforcing a fail-fast behavior. This is particularly useful for catching promise-related issues early in development and production environments.
Node.js developers working on long-running processes like servers, who need to ensure unhandled promise rejections are immediately visible and actionable. It is not intended for authors of reusable modules or libraries.
Developers choose hard-rejection because it provides a straightforward, zero-configuration way to enforce immediate failure on unhandled promise rejections, eliminating silent bugs. Its simplicity and focus on top-level processes make it a reliable tool for improving application robustness without verbose error-handling code.
Make unhandled promise rejections fail hard right away instead of the default silent fail
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Immediately terminates the Node.js process on unhandled promise rejections, preventing silent bugs as described in the README's problem statement.
Allows passing a custom function to log error stacks before exit, providing flexibility in error output as shown in the API documentation.
Offers a /register import that automatically installs the handler, simplifying setup for modern JavaScript modules as demonstrated in the usage examples.
With Node.js 15 and above, the default behavior is to throw on unhandled rejections, making this package unnecessary for recent versions, as acknowledged in the README.
Crashes the process immediately, which might interrupt legitimate future handling of rejections, a risk the README explicitly warns users about.