Skip to content

Commit 0e8e266

Browse files
committed
repl: propagate setupHistory callback errors (fixes #60837)
1 parent aafd152 commit 0e8e266

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/internal/repl/history.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ class ReplHistory {
396396
}
397397
}
398398

399+
// === FIXED VERSION FOR ISSUE #60837 ===
399400
[kReplHistoryMessage]() {
400401
if (this[kHistory].length === 0) {
401402
ReplHistory[kWriteToOutput](
@@ -405,8 +406,16 @@ class ReplHistory {
405406
'a valid, user-writable path to enable.\n',
406407
);
407408
}
408-
this[kContext]._historyPrev = this.historyPrev;
409-
return this[kContext]._historyPrev();
409+
410+
const prev = this.historyPrev;
411+
this[kContext]._historyPrev = prev;
412+
413+
// Fix: Propagate callback errors
414+
try {
415+
return prev.call(this[kContext]);
416+
} catch (err) {
417+
process.nextTick(() => { throw err; });
418+
}
410419
}
411420
}
412421

0 commit comments

Comments
 (0)