From de9d5ff287c576c495f5c132fdf4b826f1356e5a Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 5 Feb 2019 21:47:08 +0100 Subject: 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 Reviewed-By: Gus Caplan Reviewed-By: Benjamin Gruenbaum Reviewed-By: Minwoo Jung Reviewed-By: Colin Ihrig --- test/parallel/test-worker-syntax-error-file.js | 1 + test/parallel/test-worker-syntax-error.js | 1 + 2 files changed, 2 insertions(+) (limited to 'test') 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 { -- cgit v1.2.3