diff --git a/lib/internal/error-serdes.js b/lib/internal/error-serdes.js index 8647e3b78d19ec..4a07e92d769cf3 100644 --- a/lib/internal/error-serdes.js +++ b/lib/internal/error-serdes.js @@ -48,7 +48,7 @@ function TryGetAllProperties(object, target = object) { function GetConstructors(object) { const constructors = []; - for (var current = object; + for (let current = object; current !== null; current = Object.getPrototypeOf(current)) { const desc = Object.getOwnPropertyDescriptor(current, 'constructor'); @@ -82,7 +82,7 @@ function serializeError(error) { if (typeof error === 'object' && ObjectPrototype.toString(error) === '[object Error]') { const constructors = GetConstructors(error); - for (var i = 0; i < constructors.length; i++) { + for (let i = 0; i < constructors.length; i++) { const name = GetName(constructors[i]); if (errorConstructorNames.has(name)) { const serialized = serialize({