diff --git a/lib/internal/repl/history.js b/lib/internal/repl/history.js index ed63ba01cb1be1..bac9db145ebfcf 100644 --- a/lib/internal/repl/history.js +++ b/lib/internal/repl/history.js @@ -321,7 +321,11 @@ class ReplHistory { this[kContext].once('flushHistory', () => { if (!this[kContext].closed) { this[kContext].resume(); - onReadyCallback(null, this[kContext]); + try { + onReadyCallback(null, this[kContext]); + } catch (err) { + process.nextTick(() => { throw err; }); + } } }); @@ -345,7 +349,11 @@ class ReplHistory { this.historyPrev = this[kContext]._historyPrev; this[kContext]._historyPrev = this[kReplHistoryMessage].bind(this); this[kContext].resume(); - return onReadyCallback(null, this[kContext]); + try { + return onReadyCallback(null, this[kContext]); + } catch (callbackErr) { + process.nextTick(() => { throw callbackErr; }); + } } [kOnLine]() {