From 79bfb0416b0ca1b386806c450ffaa82dae7613fd 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 Backport-PR-URL: https://github.com/nodejs/node/pull/39446 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 668709eccce380..528416c75aaee1 100644 --- a/lib/internal/inspector/_inspect.js +++ b/lib/internal/inspector/_inspect.js @@ -203,8 +203,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 128ae697105a3d..cad22aed83cc2b 100644 --- a/lib/internal/inspector/inspect_repl.js +++ b/lib/internal/inspector/inspect_repl.js @@ -1077,7 +1077,7 @@ function createRepl(inspector) { .then(() => Runtime.runIfWaitingForDebugger()); } - return function startRepl() { + return async function startRepl() { inspector.client.on('close', () => { resetOnStart(); }); @@ -1085,6 +1085,9 @@ function createRepl(inspector) { initAfterStart(); }); + // Init once for the initial connection + await initAfterStart(); + const replOptions = { prompt: 'debug> ', input: inspector.stdin, @@ -1103,9 +1106,6 @@ function createRepl(inspector) { repl.emit('SIGINT'); }); - // Init once for the initial connection - initAfterStart(); - return repl; }; }