summaryrefslogtreecommitdiff
path: root/lib
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 /lib
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 'lib')
-rw-r--r--lib/internal/error-serdes.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/internal/error-serdes.js b/lib/internal/error-serdes.js
index 6b88f100c8..7b4b416b80 100644
--- a/lib/internal/error-serdes.js
+++ b/lib/internal/error-serdes.js
@@ -86,7 +86,7 @@ function serializeError(error) {
if (typeof error === 'object' &&
ObjectPrototypeToString(error) === '[object Error]') {
const constructors = GetConstructors(error);
- for (var i = constructors.length - 1; i >= 0; i--) {
+ for (var i = 0; i < constructors.length; i++) {
const name = GetName(constructors[i]);
if (errorConstructorNames.has(name)) {
try { error.stack; } catch {}