Skip to content

Commit

Permalink
debugger: wait for V8 debugger to be enabled
Browse files Browse the repository at this point in the history
Refs: #38273 (comment)

PR-URL: #38811
Backport-PR-URL: #39446
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Beth Griggs <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
targos authored and richardlau committed Jul 22, 2021
1 parent 721edef commit 79bfb04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/internal/inspector/_inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions lib/internal/inspector/inspect_repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1077,14 +1077,17 @@ function createRepl(inspector) {
.then(() => Runtime.runIfWaitingForDebugger());
}

return function startRepl() {
return async function startRepl() {
inspector.client.on('close', () => {
resetOnStart();
});
inspector.client.on('ready', () => {
initAfterStart();
});

// Init once for the initial connection
await initAfterStart();

const replOptions = {
prompt: 'debug> ',
input: inspector.stdin,
Expand All @@ -1103,9 +1106,6 @@ function createRepl(inspector) {
repl.emit('SIGINT');
});

// Init once for the initial connection
initAfterStart();

return repl;
};
}
Expand Down

0 comments on commit 79bfb04

Please sign in to comment.