diff --git a/lib/internal/error-serdes.js b/lib/internal/error-serdes.js index 744098af5348b8..1216c56bffe5c2 100644 --- a/lib/internal/error-serdes.js +++ b/lib/internal/error-serdes.js @@ -54,7 +54,7 @@ function TryGetAllProperties(object, target = object) { function GetConstructors(object) { const constructors = []; - for (var current = object; + for (let current = object; current !== null; current = ObjectGetPrototypeOf(current)) { const desc = ObjectGetOwnPropertyDescriptor(current, 'constructor'); @@ -88,7 +88,7 @@ function serializeError(error) { if (typeof error === 'object' && ObjectPrototypeToString(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({