summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-02-05 21:47:08 +0100
committerAnna Henningsen <anna@addaleax.net>2019-02-08 21:30:59 +0100
commitde9d5ff287c576c495f5c132fdf4b826f1356e5a (patch)
tree2f731be5a9e6294613e1484a4a5e80bb19a65466 /test
parent8b79c15b6f82c79c35bf57927342ac8e44e1e4b7 (diff)
downloadandroid-node-v8-de9d5ff287c576c495f5c132fdf4b826f1356e5a.tar.gz
android-node-v8-de9d5ff287c576c495f5c132fdf4b826f1356e5a.tar.bz2
android-node-v8-de9d5ff287c576c495f5c132fdf4b826f1356e5a.zip
worker: use correct ctor for error serialization
When serializing errors, use the error constructor that is closest to the object itself in the prototype chain. The previous practice of walking downwards meant that `Error` would usually be the first constructor that is used, even when a more specific one would be available/appropriate, because it is the base class of the other common error types. PR-URL: https://github.com/nodejs/node/pull/25951 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-worker-syntax-error-file.js1
-rw-r--r--test/parallel/test-worker-syntax-error.js1
2 files changed, 2 insertions, 0 deletions
diff --git a/test/parallel/test-worker-syntax-error-file.js b/test/parallel/test-worker-syntax-error-file.js
index 87ed6c3c92..ca42c17480 100644
--- a/test/parallel/test-worker-syntax-error-file.js
+++ b/test/parallel/test-worker-syntax-error-file.js
@@ -10,6 +10,7 @@ if (!process.env.HAS_STARTED_WORKER) {
const w = new Worker(fixtures.path('syntax', 'bad_syntax.js'));
w.on('message', common.mustNotCall());
w.on('error', common.mustCall((err) => {
+ assert.strictEqual(err.constructor, SyntaxError);
assert(/SyntaxError/.test(err));
}));
} else {
diff --git a/test/parallel/test-worker-syntax-error.js b/test/parallel/test-worker-syntax-error.js
index 86c20ab29d..5c91eb2d25 100644
--- a/test/parallel/test-worker-syntax-error.js
+++ b/test/parallel/test-worker-syntax-error.js
@@ -9,6 +9,7 @@ if (!process.env.HAS_STARTED_WORKER) {
const w = new Worker('abc)', { eval: true });
w.on('message', common.mustNotCall());
w.on('error', common.mustCall((err) => {
+ assert.strictEqual(err.constructor, SyntaxError);
assert(/SyntaxError/.test(err));
}));
} else {