Skip to content

Commit c96e5cb

Browse files
ljharbmarco-ippolito
authored andcommitted
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: #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>
1 parent 20501a7 commit c96e5cb

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/domain.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const {
4040
ReflectApply,
4141
SafeMap,
4242
SafeWeakMap,
43+
StringPrototypeRepeat,
4344
Symbol,
4445
} = primordials;
4546

@@ -131,7 +132,7 @@ const domainRequireStack = new Error('require(`domain`) at this point').stack;
131132
const { setUncaughtExceptionCaptureCallback } = process;
132133
process.setUncaughtExceptionCaptureCallback = function(fn) {
133134
const err = new ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE();
134-
err.stack = err.stack + '\n' + '-'.repeat(40) + '\n' + domainRequireStack;
135+
err.stack += `\n${StringPrototypeRepeat('-', 40)}\n${domainRequireStack}`;
135136
throw err;
136137
};
137138

lib/repl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,15 +1528,15 @@ function complete(line, callback) {
15281528
let p;
15291529
if ((typeof obj === 'object' && obj !== null) ||
15301530
typeof obj === 'function') {
1531-
memberGroups.push(filteredOwnPropertyNames(obj));
1531+
ArrayPrototypePush(memberGroups, filteredOwnPropertyNames(obj));
15321532
p = ObjectGetPrototypeOf(obj);
15331533
} else {
15341534
p = obj.constructor ? obj.constructor.prototype : null;
15351535
}
15361536
// Circular refs possible? Let's guard against that.
15371537
let sentinel = 5;
15381538
while (p !== null && sentinel-- !== 0) {
1539-
memberGroups.push(filteredOwnPropertyNames(p));
1539+
ArrayPrototypePush(memberGroups, filteredOwnPropertyNames(p));
15401540
p = ObjectGetPrototypeOf(p);
15411541
}
15421542
} catch {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy