From f1cbaea74b432a49af61293e005f8d7e7f56325c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Wed, 26 May 2021 09:00:14 +0200 Subject: [PATCH] debugger: wait for V8 debugger to be enabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://github.com/nodejs/node/pull/38273#issuecomment-848438189 PR-URL: https://github.com/nodejs/node/pull/38811 Reviewed-By: Antoine du Hamel Reviewed-By: Richard Lau Reviewed-By: Beth Griggs Reviewed-By: Gerhard Stöbich Reviewed-By: Rich Trott --- lib/internal/inspector/_inspect.js | 4 ++-- lib/internal/inspector/inspect_repl.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) 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; }; }