diff --git a/lib/repl.js b/lib/repl.js index bcbe3a292df910..4c44833699453a 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -965,7 +965,7 @@ REPLServer.prototype.createContext = function() { } const module = new CJSModule(''); - module.paths = CJSModule._resolveLookupPaths('', parentModule) || []; + module.paths = CJSModule._resolveLookupPaths('', parentModule); ObjectDefineProperty(context, 'module', { configurable: true, @@ -1321,21 +1321,17 @@ function complete(line, callback) { } // Works for non-objects try { - let sentinel = 5; let p; if (typeof obj === 'object' || typeof obj === 'function') { p = ObjectGetPrototypeOf(obj); } else { p = obj.constructor ? obj.constructor.prototype : null; } - while (p !== null) { + // Circular refs possible? Let's guard against that. + let sentinel = 5; + while (p !== null && sentinel-- !== 0) { memberGroups.push(filteredOwnPropertyNames(p)); p = ObjectGetPrototypeOf(p); - // Circular refs possible? Let's guard against that. - sentinel--; - if (sentinel <= 0) { - break; - } } } catch {} }