0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 13:09:21 +01:00

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.

PR-URL: https://github.com/nodejs/node/pull/31457
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
Jordan Harband 2024-09-17 10:08:43 -05:00 committed by GitHub
parent 421977cd48
commit 7014e50ca3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -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;
};

View File

@ -1528,7 +1528,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;
@ -1536,7 +1536,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 {