Can I get the future unhandled promise rejection behaviour now?

Erik B picture Erik B · Aug 1, 2018 · Viewed 8.4k times · Source

In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

My pipeline passed when it should have failed and deployed a version that is crashing on launch. If Node.js would have exited with a non-zero exit code, the pipeline would have failed and the bad version wouldn't have been deployed.

Is there a way to make Node.js exit with a non-zero exit code when it encounters an unhandled promise rejection, that doesn't require me to wait for the future?

Answer

No_name picture No_name · Aug 22, 2019

For node 12 and later:

node --unhandled-rejections=strict