From 92994beca96fe9bcb18d196c88ad4993d3a4a0be Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 22 Jan 2020 00:46:07 -0800 Subject: [PATCH] lib: the REPL should survive deletion of Array.prototype methods Specifically, `delete Array.prototype.lastIndexOf` immediately crashes the REPL, as does deletion of a few other Array prototype methods. --- lib/domain.js | 3 ++- lib/repl.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/domain.js b/lib/domain.js index 7da672a3691560..03d240e98d4506 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -40,6 +40,7 @@ const { ReflectApply, SafeMap, SafeWeakMap, + StringPrototypeRepeat, Symbol, } = primordials; @@ -131,7 +132,7 @@ const domainRequireStack = new Error('require(`domain`) at this point').stack; const { setUncaughtExceptionCaptureCallback } = process; process.setUncaughtExceptionCaptureCallback = function(fn) { const err = new ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE(); - err.stack = err.stack + '\n' + '-'.repeat(40) + '\n' + domainRequireStack; + err.stack += `\n${StringPrototypeRepeat('-', 40)}\n${domainRequireStack}`; throw err; }; diff --git a/lib/repl.js b/lib/repl.js index 6e2d8120ad2167..40b8ee175d120e 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1526,7 +1526,7 @@ function complete(line, callback) { let p; if ((typeof obj === 'object' && obj !== null) || typeof obj === 'function') { - memberGroups.push(filteredOwnPropertyNames(obj)); + ArrayPrototypePush(memberGroups, filteredOwnPropertyNames(obj)); p = ObjectGetPrototypeOf(obj); } else { p = obj.constructor ? obj.constructor.prototype : null; @@ -1534,7 +1534,7 @@ function complete(line, callback) { // Circular refs possible? Let's guard against that. let sentinel = 5; while (p !== null && sentinel-- !== 0) { - memberGroups.push(filteredOwnPropertyNames(p)); + ArrayPrototypePush(memberGroups, filteredOwnPropertyNames(p)); p = ObjectGetPrototypeOf(p); } } catch {