From dca08152cbb6024376fe6280d5fdc956682a4046 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 19 Apr 2017 19:17:31 +0200 Subject: [PATCH] test: introduce `common.crashOnUnhandledRejection` Ref: https://github.com/nodejs/node/pull/12442 PR-URL: https://github.com/nodejs/node/pull/12489 Reviewed-By: Matthew Loring Reviewed-By: Julien Gilli Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell --- test/common.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/common.js b/test/common.js index a3540cb11a..2d61fb0dc5 100644 --- a/test/common.js +++ b/test/common.js @@ -677,3 +677,9 @@ exports.getArrayBufferViews = function getArrayBufferViews(buf) { } return out; }; + +// Crash the process on unhandled rejections. +exports.crashOnUnhandledRejection = function() { + process.on('unhandledRejection', + (err) => process.nextTick(() => { throw err; })); +};