Re:Node.js 15.0
by avolcano on Friday October 23, 2020 @12:07PM
(#24870960)
Glad to see "throw on unhandled rejections" make it into Node, finally! I can stop carting around this little bit of code I used in every Node API I wrote:
Had become as second-nature for me as "set -euo pipefail".
[ Parent
| on HN ]
idk if you've ever run into it, but `process.exit` has been a bit of a footgun in our node apps due to broken pipes and (sometimes) async io with `console`
we instead use
process.on('unhandledRejection', (reason) => {
throw reason;
});
which, as long as you havent handled `uncaughtException`, prints the stack trace and aborts.Very happy to see this too!
In Emscripten we've had to emit a handler like that by default, so that test suites don't silently ignore errors. Being able to not emit it will avoid some code size and annoyances users have had.