Skip to content

Commit 0217197

Browse files
Jan Kremsaddaleax
Jan Krems
authored andcommitted
deps: update node-inspect to v1.11.2
PR-URL: #12363 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
1 parent 7fd2923 commit 0217197

19 files changed

+249
-104
lines changed

deps/node-inspect/CHANGELOG.md

+26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
### 1.11.2
2+
3+
* [`42e0cd1`](https://github.com/nodejs/node-inspect/commit/42e0cd111d89ed09faba1c0ec45089b0b44de011) **fix:** look for generic hint text
4+
5+
6+
### 1.11.1
7+
8+
* Prefer --inspect-brk over --debug-brk - **[@ofrobots](https://github.com/ofrobots)** [#43](https://github.com/nodejs/node-inspect/pull/43)
9+
- [`2c1ed27`](https://github.com/nodejs/node-inspect/commit/2c1ed27ee44d9aebb3c5ac50039abae8166a54e3) **fix:** use --inspect-brk with Node 8+
10+
11+
12+
### 1.11.0
13+
14+
* doc: add profile and heap to help - **[@joshgav](https://github.com/joshgav)** [#39](https://github.com/nodejs/node-inspect/pull/39)
15+
- [`f64c920`](https://github.com/nodejs/node-inspect/commit/f64c9205bd8382289660aa677d3ac192a9c81fd5) **doc:** add profile and heap to help
16+
* Update test suite to pass on latest nightly - **[@jkrems](https://github.com/jkrems)** [#36](https://github.com/nodejs/node-inspect/pull/36)
17+
- [`41148d7`](https://github.com/nodejs/node-inspect/commit/41148d74a2d563eea3b7ad5463622b6b9fd4c46e) **test:** Remove outdated test
18+
- [`2c224c5`](https://github.com/nodejs/node-inspect/commit/2c224c551619e386e80fc3154cc14562cac063b9) **test:** Accept any kind of "break"
19+
- [`22bf349`](https://github.com/nodejs/node-inspect/commit/22bf349bc86d7bf6fd449791c9d1e7eaf66c2681) **test:** Adjust for v8 5.7
20+
- [`6ce8c16`](https://github.com/nodejs/node-inspect/commit/6ce8c165c45a491bea8cfb3c67d2ae80e7c34dcb) **test:** Revert to old assertions
21+
* Verify custom port support - **[@jkrems](https://github.com/jkrems)** [#41](https://github.com/nodejs/node-inspect/pull/41)
22+
- [`e3a489f`](https://github.com/nodejs/node-inspect/commit/e3a489f23b089d3d57a25d5efe40daf06de63e23) **test:** custom port
23+
* Support for debugging a pid - **[@jkrems](https://github.com/jkrems)** [#37](https://github.com/nodejs/node-inspect/pull/37)
24+
- [`4179506`](https://github.com/nodejs/node-inspect/commit/4179506a4d546bac2c93b2a7ff491b1fa4494fd9) **feat:** Support for debugging a pid
25+
26+
127
### 1.10.6
228

329
* chore: Fix usage text for embedded mode - **[@addaleax](https://github.com/addaleax)** [#20](https://github.com/nodejs/node-inspect/pull/20)

deps/node-inspect/lib/_inspect.js

+75-59
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const [ InspectClient, createRepl ] =
4242

4343
const debuglog = util.debuglog('inspect');
4444

45-
const DEBUG_PORT_PATTERN = /^--(?:debug|inspect)-port=(\d+)$/;
45+
const DEBUG_PORT_PATTERN = /^--(?:debug|inspect)(?:-port|-brk)?=(\d{1,5})$/;
4646
function getDefaultPort() {
4747
for (const arg of process.execArgv) {
4848
const match = arg.match(DEBUG_PORT_PATTERN);
@@ -53,54 +53,6 @@ function getDefaultPort() {
5353
return 9229;
5454
}
5555

56-
function runScript(script, scriptArgs, inspectPort, childPrint) {
57-
return new Promise((resolve) => {
58-
const needDebugBrk = process.version.match(/^v(6|7)\./);
59-
const args = (needDebugBrk ?
60-
['--inspect', `--debug-brk=${inspectPort}`] :
61-
[`--inspect-brk=${inspectPort}`])
62-
.concat([script], scriptArgs);
63-
const child = spawn(process.execPath, args);
64-
child.stdout.setEncoding('utf8');
65-
child.stderr.setEncoding('utf8');
66-
child.stdout.on('data', childPrint);
67-
child.stderr.on('data', childPrint);
68-
69-
let output = '';
70-
function waitForListenHint(text) {
71-
output += text;
72-
if (/chrome-devtools:\/\//.test(output)) {
73-
child.stderr.removeListener('data', waitForListenHint);
74-
resolve(child);
75-
}
76-
}
77-
78-
child.stderr.on('data', waitForListenHint);
79-
});
80-
}
81-
82-
function createAgentProxy(domain, client) {
83-
const agent = new EventEmitter();
84-
agent.then = (...args) => {
85-
// TODO: potentially fetch the protocol and pretty-print it here.
86-
const descriptor = {
87-
[util.inspect.custom](depth, { stylize }) {
88-
return stylize(`[Agent ${domain}]`, 'special');
89-
},
90-
};
91-
return Promise.resolve(descriptor).then(...args);
92-
};
93-
94-
return new Proxy(agent, {
95-
get(target, name) {
96-
if (name in target) return target[name];
97-
return function callVirtualMethod(params) {
98-
return client.callMethod(`${domain}.${name}`, params);
99-
};
100-
},
101-
});
102-
}
103-
10456
function portIsFree(host, port, timeout = 2000) {
10557
const retryDelay = 150;
10658
let didTimeOut = false;
@@ -140,6 +92,57 @@ function portIsFree(host, port, timeout = 2000) {
14092
});
14193
}
14294

95+
function runScript(script, scriptArgs, inspectHost, inspectPort, childPrint) {
96+
return portIsFree(inspectHost, inspectPort)
97+
.then(() => {
98+
return new Promise((resolve) => {
99+
const needDebugBrk = process.version.match(/^v(6|7)\./);
100+
const args = (needDebugBrk ?
101+
['--inspect', `--debug-brk=${inspectPort}`] :
102+
[`--inspect-brk=${inspectPort}`])
103+
.concat([script], scriptArgs);
104+
const child = spawn(process.execPath, args);
105+
child.stdout.setEncoding('utf8');
106+
child.stderr.setEncoding('utf8');
107+
child.stdout.on('data', childPrint);
108+
child.stderr.on('data', childPrint);
109+
110+
let output = '';
111+
function waitForListenHint(text) {
112+
output += text;
113+
if (/Debugger listening on/.test(output)) {
114+
child.stderr.removeListener('data', waitForListenHint);
115+
resolve(child);
116+
}
117+
}
118+
119+
child.stderr.on('data', waitForListenHint);
120+
});
121+
});
122+
}
123+
124+
function createAgentProxy(domain, client) {
125+
const agent = new EventEmitter();
126+
agent.then = (...args) => {
127+
// TODO: potentially fetch the protocol and pretty-print it here.
128+
const descriptor = {
129+
[util.inspect.custom](depth, { stylize }) {
130+
return stylize(`[Agent ${domain}]`, 'special');
131+
},
132+
};
133+
return Promise.resolve(descriptor).then(...args);
134+
};
135+
136+
return new Proxy(agent, {
137+
get(target, name) {
138+
if (name in target) return target[name];
139+
return function callVirtualMethod(params) {
140+
return client.callMethod(`${domain}.${name}`, params);
141+
};
142+
},
143+
});
144+
}
145+
143146
class NodeInspector {
144147
constructor(options, stdin, stdout) {
145148
this.options = options;
@@ -153,6 +156,7 @@ class NodeInspector {
153156
this._runScript = runScript.bind(null,
154157
options.script,
155158
options.scriptArgs,
159+
options.host,
156160
options.port,
157161
this.childPrint.bind(this));
158162
} else {
@@ -221,12 +225,7 @@ class NodeInspector {
221225
this.killChild();
222226
const { host, port } = this.options;
223227

224-
const runOncePortIsFree = () => {
225-
return portIsFree(host, port)
226-
.then(() => this._runScript());
227-
};
228-
229-
return runOncePortIsFree().then((child) => {
228+
return this._runScript().then((child) => {
230229
this.child = child;
231230

232231
let connectionAttempts = 0;
@@ -296,6 +295,7 @@ function parseArgv([target, ...args]) {
296295

297296
const hostMatch = target.match(/^([^:]+):(\d+)$/);
298297
const portMatch = target.match(/^--port=(\d+)$/);
298+
299299
if (hostMatch) {
300300
// Connecting to remote debugger
301301
// `node-inspect localhost:9229`
@@ -304,16 +304,31 @@ function parseArgv([target, ...args]) {
304304
isRemote = true;
305305
script = null;
306306
} else if (portMatch) {
307-
// Start debugger on custom port
308-
// `node debug --port=8058 app.js`
307+
// start debugee on custom port
308+
// `node inspect --port=9230 script.js`
309309
port = parseInt(portMatch[1], 10);
310310
script = args[0];
311311
scriptArgs = args.slice(1);
312+
} else if (args.length === 1 && /^\d+$/.test(args[0]) && target === '-p') {
313+
// Start debugger against a given pid
314+
const pid = parseInt(args[0], 10);
315+
try {
316+
process._debugProcess(pid);
317+
} catch (e) {
318+
if (e.code === 'ESRCH') {
319+
/* eslint-disable no-console */
320+
console.error(`Target process: ${pid} doesn't exist.`);
321+
/* eslint-enable no-console */
322+
process.exit(1);
323+
}
324+
throw e;
325+
}
326+
script = null;
327+
isRemote = true;
312328
}
313329

314330
return {
315-
host, port,
316-
isRemote, script, scriptArgs,
331+
host, port, isRemote, script, scriptArgs,
317332
};
318333
}
319334

@@ -328,6 +343,7 @@ function startInspect(argv = process.argv.slice(2),
328343

329344
console.error(`Usage: ${invokedAs} script.js`);
330345
console.error(` ${invokedAs} <host>:<port>`);
346+
console.error(` ${invokedAs} -p <pid>`);
331347
process.exit(1);
332348
}
333349

deps/node-inspect/lib/internal/inspect_repl.js

+9
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ repl Enter a debug repl that works like exec
6767
6868
scripts List application scripts that are currently loaded
6969
scripts(true) List all scripts (including node-internals)
70+
71+
profile Start CPU profiling session.
72+
profileEnd Stop current CPU profiling session.
73+
profiles Array of completed CPU profiling sessions.
74+
profiles[n].save(filepath = 'node.cpuprofile')
75+
Save CPU profiling session to disk as JSON.
76+
77+
takeHeapSnapshot(filepath = 'node.heapsnapshot')
78+
Take a heap snapshot and save to disk as JSON.
7079
`.trim();
7180

7281
const FUNCTION_NAME_PATTERN = /^(?:function\*? )?([^(\s]+)\(/;

deps/node-inspect/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-inspect",
3-
"version": "1.10.6",
3+
"version": "1.11.2",
44
"description": "Node Inspect",
55
"license": "MIT",
66
"main": "lib/_inspect.js",
@@ -15,7 +15,7 @@
1515
},
1616
"scripts": {
1717
"pretest": "eslint --rulesdir=tools/eslint-rules lib test",
18-
"test": "tap \"test/**/*.test.js\"",
18+
"test": "tap test",
1919
"posttest": "nlm verify"
2020
},
2121
"nlm": {

deps/node-inspect/test/cli/backtrace.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test('display and navigate backtrace', (t) => {
1414
throw error;
1515
}
1616

17-
return cli.waitFor(/break/)
17+
return cli.waitForInitialBreak()
1818
.then(() => cli.waitForPrompt())
1919
.then(() => cli.stepCommand('c'))
2020
.then(() => cli.command('bt'))

deps/node-inspect/test/cli/break.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test('stepping through breakpoints', (t) => {
1414
throw error;
1515
}
1616

17-
return cli.waitFor(/break/)
17+
return cli.waitForInitialBreak()
1818
.then(() => cli.waitForPrompt())
1919
.then(() => {
2020
t.match(
@@ -132,7 +132,7 @@ test('sb before loading file', (t) => {
132132
throw error;
133133
}
134134

135-
return cli.waitFor(/break/)
135+
return cli.waitForInitialBreak()
136136
.then(() => cli.waitForPrompt())
137137
.then(() => cli.command('sb("other.js", 3)'))
138138
.then(() => {
@@ -161,7 +161,7 @@ test('clearBreakpoint', (t) => {
161161
throw error;
162162
}
163163

164-
return cli.waitFor(/break/)
164+
return cli.waitForInitialBreak()
165165
.then(() => cli.waitForPrompt())
166166
.then(() => cli.command('sb("break.js", 3)'))
167167
.then(() => cli.command('sb("break.js", 9)'))

deps/node-inspect/test/cli/exceptions.test.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ test('break on (uncaught) exceptions', (t) => {
1414
throw error;
1515
}
1616

17-
return cli.waitFor(/break/)
17+
return cli.waitForInitialBreak()
1818
.then(() => cli.waitForPrompt())
1919
.then(() => {
2020
t.match(cli.output, `break in ${script}:1`);
2121
})
2222
// making sure it will die by default:
2323
.then(() => cli.command('c'))
24-
.then(() => cli.waitFor(/disconnect/))
24+
// TODO: Remove FATAL ERROR once node doesn't show a FATAL ERROR anymore
25+
.then(() => cli.waitFor(/disconnect|FATAL ERROR/))
2526

2627
// Next run: With `breakOnException` it pauses in both places
2728
.then(() => cli.stepCommand('r'))
29+
.then(() => cli.waitForInitialBreak())
2830
.then(() => {
2931
t.match(cli.output, `break in ${script}:1`);
3032
})
@@ -41,6 +43,7 @@ test('break on (uncaught) exceptions', (t) => {
4143
// Next run: With `breakOnUncaught` it only pauses on the 2nd exception
4244
.then(() => cli.command('breakOnUncaught'))
4345
.then(() => cli.stepCommand('r')) // also, the setting survives the restart
46+
.then(() => cli.waitForInitialBreak())
4447
.then(() => {
4548
t.match(cli.output, `break in ${script}:1`);
4649
})
@@ -52,11 +55,13 @@ test('break on (uncaught) exceptions', (t) => {
5255
// Next run: Back to the initial state! It should die again.
5356
.then(() => cli.command('breakOnNone'))
5457
.then(() => cli.stepCommand('r'))
58+
.then(() => cli.waitForInitialBreak())
5559
.then(() => {
5660
t.match(cli.output, `break in ${script}:1`);
5761
})
5862
.then(() => cli.command('c'))
59-
.then(() => cli.waitFor(/disconnect/))
63+
// TODO: Remove FATAL ERROR once node doesn't show a FATAL ERROR anymore
64+
.then(() => cli.waitFor(/disconnect|FATAL ERROR/))
6065

6166
.then(() => cli.quit())
6267
.then(null, onFatal);

deps/node-inspect/test/cli/exec.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test('examples/alive.js', (t) => {
1111
throw error;
1212
}
1313

14-
return cli.waitFor(/break/)
14+
return cli.waitForInitialBreak()
1515
.then(() => cli.waitForPrompt())
1616
.then(() => cli.command('exec [typeof heartbeat, typeof process.exit]'))
1717
.then(() => {
@@ -60,7 +60,7 @@ test('exec .scope', (t) => {
6060
throw error;
6161
}
6262

63-
return cli.waitFor(/break/)
63+
return cli.waitForInitialBreak()
6464
.then(() => cli.waitForPrompt())
6565
.then(() => cli.stepCommand('c'))
6666
.then(() => cli.command('exec .scope'))

deps/node-inspect/test/cli/help.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test('examples/empty.js', (t) => {
1111
throw error;
1212
}
1313

14-
return cli.waitFor(/break/)
14+
return cli.waitForInitialBreak()
1515
.then(() => cli.waitForPrompt())
1616
.then(() => cli.command('help'))
1717
.then(() => {

0 commit comments

Comments
 (0)