Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit 625a435

Browse files
author
Jan Krems
committed
fix: Gracefully handle delayed scriptParsed
1 parent 1ed2ec9 commit 625a435

3 files changed

Lines changed: 24 additions & 26 deletions

File tree

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
language: node_js
22
node_js:
33
- '6'
4-
before_install:
5-
- npm install -g npm@latest-2
64
before_deploy:
75
- git config --global user.email "jan.krems@gmail.com"
86
- git config --global user.name "Jan Krems"

lib/internal/inspect-repl.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function aliasProperties(target, mapping) {
106106
});
107107
}
108108

109-
function startRepl(inspector) {
109+
function createRepl(inspector) {
110110
const { Debugger } = inspector;
111111

112112
let repl; // eslint-disable-line prefer-const
@@ -349,18 +349,19 @@ function startRepl(inspector) {
349349
aliasProperties(context, SHORTCUTS);
350350
}
351351

352-
const replOptions = {
353-
prompt: 'debug> ',
354-
input: inspector.stdin,
355-
output: inspector.stdout,
356-
eval: controlEval,
357-
useGlobal: false,
358-
ignoreUndefined: true,
352+
return function startRepl() {
353+
const replOptions = {
354+
prompt: 'debug> ',
355+
input: inspector.stdin,
356+
output: inspector.stdout,
357+
eval: controlEval,
358+
useGlobal: false,
359+
ignoreUndefined: true,
360+
};
361+
repl = Repl.start(replOptions); // eslint-disable-line prefer-const
362+
initializeContext(repl.context);
363+
repl.on('reset', initializeContext);
364+
return repl;
359365
};
360-
repl = Repl.start(replOptions); // eslint-disable-line prefer-const
361-
initializeContext(repl.context);
362-
repl.on('reset', initializeContext);
363-
364-
return repl;
365366
}
366-
module.exports = startRepl;
367+
module.exports = createRepl;

lib/node-inspect.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const util = require('util');
2727
const debuglog = util.debuglog('inspect');
2828

2929
const ProtocolClient = require('./internal/inspect-protocol');
30-
const startRepl = require('./internal/inspect-repl');
30+
const createRepl = require('./internal/inspect-repl');
3131

3232
exports.port = 9229;
3333

@@ -105,25 +105,24 @@ class NodeInspector {
105105
}
106106
};
107107
this.client.on('debugEvent', this.handleDebugEvent);
108+
const startRepl = createRepl(this);
108109

109110
// Handle all possible exits
110111
process.on('exit', () => this.killChild());
111112
process.once('SIGTERM', process.exit.bind(process, 0));
112113
process.once('SIGHUP', process.exit.bind(process, 0));
113114

114115
this.run()
115-
.then(() => this._setupRepl())
116+
.then(() => {
117+
this.repl = startRepl();
118+
this.repl.on('exit', () => {
119+
process.exit(0);
120+
});
121+
this.paused = false;
122+
})
116123
.then(null, throwUnexpectedError);
117124
}
118125

119-
_setupRepl() {
120-
this.repl = startRepl(this);
121-
this.repl.on('exit', () => {
122-
process.exit(0);
123-
});
124-
this.paused = false;
125-
}
126-
127126
suspendReplWhile(fn) {
128127
this.repl.rli.pause();
129128
this.stdin.pause();

0 commit comments

Comments
 (0)