From 9c4d8ee2767a488b002da6c89eee36353b3d6f61 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 23 Apr 2021 13:53:54 -0700 Subject: [PATCH] debugger: fix race condition/deadlock on initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/38161 Backport-PR-URL: https://github.com/nodejs/node/pull/38858 Refs: https://github.com/nodejs/node/discussions/36481 Reviewed-By: Matteo Collina Reviewed-By: Jan Krems Reviewed-By: Colin Ihrig Reviewed-By: Stephen Belanger Reviewed-By: Gerhard Stöbich Reviewed-By: Michaël Zasso --- lib/internal/inspector/inspect_repl.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/internal/inspector/inspect_repl.js b/lib/internal/inspector/inspect_repl.js index 57a76b3b7f0dfb..32ee1c3f8c31ba 100644 --- a/lib/internal/inspector/inspect_repl.js +++ b/lib/internal/inspector/inspect_repl.js @@ -1062,19 +1062,16 @@ function createRepl(inspector) { } function initAfterStart() { - const setupTasks = [ - Runtime.enable(), - Profiler.enable(), - Profiler.setSamplingInterval({ interval: 100 }), - Debugger.enable(), - Debugger.setPauseOnExceptions({ state: 'none' }), - Debugger.setAsyncCallStackDepth({ maxDepth: 0 }), - Debugger.setBlackboxPatterns({ patterns: [] }), - Debugger.setPauseOnExceptions({ state: pauseOnExceptionState }), - restoreBreakpoints(), - Runtime.runIfWaitingForDebugger(), - ]; - return Promise.all(setupTasks); + return Runtime.enable() + .then(() => Profiler.enable()) + .then(() => Profiler.setSamplingInterval({ interval: 100 })) + .then(() => Debugger.enable()) + .then(() => Debugger.setPauseOnExceptions({ state: 'none' })) + .then(() => Debugger.setAsyncCallStackDepth({ maxDepth: 0 })) + .then(() => Debugger.setBlackboxPatterns({ patterns: [] })) + .then(() => Debugger.setPauseOnExceptions({ state: pauseOnExceptionState })) + .then(() => restoreBreakpoints()) + .then(() => Runtime.runIfWaitingForDebugger()) } return function startRepl() {