summaryrefslogtreecommitdiff
path: root/test/parallel/test-events-uncaught-exception-stack.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-02-26 15:46:50 +0100
committerAnna Henningsen <anna@addaleax.net>2018-03-04 21:20:43 +0000
commit68d508a9e03923a5ae6a53a1adff66c4e3f97263 (patch)
tree5994954cfd307defe8bd7805aea06f17ebf9b444 /test/parallel/test-events-uncaught-exception-stack.js
parentf2d93795bfe61a3260bf743d2247b56b83fc6f70 (diff)
downloadandroid-node-v8-68d508a9e03923a5ae6a53a1adff66c4e3f97263.tar.gz
android-node-v8-68d508a9e03923a5ae6a53a1adff66c4e3f97263.tar.bz2
android-node-v8-68d508a9e03923a5ae6a53a1adff66c4e3f97263.zip
events: show throw stack trace for uncaught exception
Show the stack trace for the `eventemitter.emit('error')` call in the case of an uncaught exception. Previously, there would be no clue in Node’s output about where the actual `throw` comes from. PR-URL: https://github.com/nodejs/node/pull/19003 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-events-uncaught-exception-stack.js')
-rw-r--r--test/parallel/test-events-uncaught-exception-stack.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/parallel/test-events-uncaught-exception-stack.js b/test/parallel/test-events-uncaught-exception-stack.js
new file mode 100644
index 0000000000..c55322a5aa
--- /dev/null
+++ b/test/parallel/test-events-uncaught-exception-stack.js
@@ -0,0 +1,16 @@
+'use strict';
+const common = require('../common');
+const assert = require('assert');
+const EventEmitter = require('events');
+
+// Tests that the error stack where the exception was thrown is *not* appended.
+
+process.on('uncaughtException', common.mustCall((err) => {
+ const lines = err.stack.split('\n');
+ assert.strictEqual(lines[0], 'Error');
+ lines.slice(1).forEach((line) => {
+ assert(/^ at/.test(line), `${line} has an unexpected format`);
+ });
+}));
+
+new EventEmitter().emit('error', new Error());