diff --git a/lib/internal/inspector/_inspect.js b/lib/internal/inspector/_inspect.js index f695fd53f1fda6..89e3def1929415 100644 --- a/lib/internal/inspector/_inspect.js +++ b/lib/internal/inspector/_inspect.js @@ -199,8 +199,8 @@ class NodeInspector { process.once('SIGTERM', exitCodeZero); process.once('SIGHUP', exitCodeZero); - PromisePrototypeCatch(PromisePrototypeThen(this.run(), () => { - const repl = startRepl(); + PromisePrototypeCatch(PromisePrototypeThen(this.run(), async () => { + const repl = await startRepl(); this.repl = repl; this.repl.on('exit', exitCodeZero); this.paused = false; diff --git a/lib/internal/inspector/inspect_repl.js b/lib/internal/inspector/inspect_repl.js index 0fcde39bfc3e2c..8988212fa83802 100644 --- a/lib/internal/inspector/inspect_repl.js +++ b/lib/internal/inspector/inspect_repl.js @@ -1146,7 +1146,7 @@ function createRepl(inspector) { return Runtime.runIfWaitingForDebugger(); } - return function startRepl() { + return async function startRepl() { inspector.client.on('close', () => { resetOnStart(); }); @@ -1154,6 +1154,9 @@ function createRepl(inspector) { initAfterStart(); }); + // Init once for the initial connection + await initAfterStart(); + const replOptions = { prompt: 'debug> ', input: inspector.stdin, @@ -1172,9 +1175,6 @@ function createRepl(inspector) { repl.emit('SIGINT'); }); - // Init once for the initial connection - initAfterStart(); - return repl; }; }