summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCameron Little <cameron@camlittle.com>2017-03-13 09:07:06 -0700
committerAnna Henningsen <anna@addaleax.net>2017-04-30 01:00:46 +0200
commita3132b0aa5721ffb8ed0ee150b9f2486449f60bb (patch)
tree89976a8d452dfa567c1d28ff28f7802cd6823b22 /test
parent74f61e8e1fba908e05d087a1130930da925cce5b (diff)
downloadandroid-node-v8-a3132b0aa5721ffb8ed0ee150b9f2486449f60bb.tar.gz
android-node-v8-a3132b0aa5721ffb8ed0ee150b9f2486449f60bb.tar.bz2
android-node-v8-a3132b0aa5721ffb8ed0ee150b9f2486449f60bb.zip
process: cast promise rejection reason to string
The unhandled promise rejection warning uses a template literal and prints the reason a promise was rejected. If rejecting with a symbol, the symbol failed to convert to a string and the process crashed. Now, symbols are casted to strings and the process does not crash. Fixes: https://github.com/nodejs/node/issues/11637 PR-URL: https://github.com/nodejs/node/pull/11640 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-promises-unhandled-symbol-rejections.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/parallel/test-promises-unhandled-symbol-rejections.js b/test/parallel/test-promises-unhandled-symbol-rejections.js
new file mode 100644
index 0000000000..a60a5f2e8a
--- /dev/null
+++ b/test/parallel/test-promises-unhandled-symbol-rejections.js
@@ -0,0 +1,18 @@
+'use strict';
+const common = require('../common');
+
+const expectedDeprecationWarning = 'Unhandled promise rejections are ' +
+ 'deprecated. In the future, promise ' +
+ 'rejections that are not handled will ' +
+ 'terminate the Node.js process with a ' +
+ 'non-zero exit code.';
+const expectedPromiseWarning = 'Unhandled promise rejection (rejection id: ' +
+ '1): Symbol()';
+
+common.expectWarning({
+ DeprecationWarning: expectedDeprecationWarning,
+ UnhandledPromiseRejectionWarning: expectedPromiseWarning,
+});
+
+// ensure this doesn't crash
+Promise.reject(Symbol());