diff --git a/lib/_inspect.js b/lib/_inspect.js index e80a516..9948fcf 100644 --- a/lib/_inspect.js +++ b/lib/_inspect.js @@ -160,38 +160,40 @@ class NodeInspector { this.child.kill(); this.child = null; } + return new Promise((resolve) => setTimeout(resolve, 2000)); } run() { - this.killChild(); - return this._runScript().then((child) => { - this.child = child; - - let connectionAttempts = 0; - const attemptConnect = () => { - ++connectionAttempts; - debuglog('connection attempt #%d', connectionAttempts); - this.stdout.write('.'); - return this.client.connect() - .then(() => { - debuglog('connection established'); - this.stdout.write(' ok'); - }, (error) => { - debuglog('connect failed', error); - // If it's failed to connect 10 times then print failed message - if (connectionAttempts >= 10) { - this.stdout.write(' failed to connect, please retry\n'); - process.exit(1); - } - - return new Promise((resolve) => setTimeout(resolve, 500)) - .then(attemptConnect); - }); - }; - - const { host, port } = this.options; - this.print(`connecting to ${host}:${port} ..`, true); - return attemptConnect(); + return this.killChild().then(() => { + return this._runScript().then((child) => { + this.child = child; + + let connectionAttempts = 0; + const attemptConnect = () => { + ++connectionAttempts; + debuglog('connection attempt #%d', connectionAttempts); + this.stdout.write('.'); + return this.client.connect() + .then(() => { + debuglog('connection established'); + this.stdout.write(' ok'); + }, (error) => { + debuglog('connect failed', error); + // If it's failed to connect 10 times then print failed message + if (connectionAttempts >= 10) { + this.stdout.write(' failed to connect, please retry\n'); + process.exit(1); + } + + return new Promise((resolve) => setTimeout(resolve, 500)) + .then(attemptConnect); + }); + }; + + const { host, port } = this.options; + this.print(`connecting to ${host}:${port} ..`, true); + return attemptConnect(); + }); }); } diff --git a/lib/internal/inspect_repl.js b/lib/internal/inspect_repl.js index e246b70..3157ce3 100644 --- a/lib/internal/inspect_repl.js +++ b/lib/internal/inspect_repl.js @@ -752,6 +752,7 @@ function createRepl(inspector) { if (!newBreakpoints.length) return; Promise.all(newBreakpoints).then((results) => { print(`${results.length} breakpoints restored.`); + repl.displayPrompt(); }); } diff --git a/test/cli/start-cli.js b/test/cli/start-cli.js index 267aac5..8cf158e 100644 --- a/test/cli/start-cli.js +++ b/test/cli/start-cli.js @@ -42,7 +42,7 @@ function startCLI(args) { return output; }, - waitFor(pattern, timeout = 2000) { + waitFor(pattern, timeout = 5000) { function checkPattern(str) { if (Array.isArray(pattern)) { return pattern.every((p) => p.test(str)); @@ -84,7 +84,7 @@ function startCLI(args) { }); }, - waitForPrompt(timeout = 2000) { + waitForPrompt(timeout = 5000) { return this.waitFor(/>\s+$/, timeout); },