Skip to content

Commit a7e4b02

Browse files
Jan Kremsitaloacasas
Jan Krems
authored andcommitted
deps: Add node-inspect 1.10.6
This updates the bundled `node-inspect` to 1.10.6. Highlights: * `node --debug-port=1234 inspect` respects the custom port. * Test stability improvements on various platforms. Compare: nodejs/node-inspect@v1.10.4...v1.10.6 PR-URL: #11869 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent a5f7393 commit a7e4b02

19 files changed

+207
-71
lines changed

deps/node-inspect/CHANGELOG.md

+27
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
### 1.10.6
2+
3+
* chore: Fix usage text for embedded mode - **[@addaleax](https://github.com/addaleax)** [#20](https://github.com/nodejs/node-inspect/pull/20)
4+
- [`b0779f5`](https://github.com/nodejs/node-inspect/commit/b0779f597104e9ada5681f64d7e714525b753511) **chore:** Fix usage text for embedded mode
5+
* print 'ok' after connection - **[@ofrobots](https://github.com/ofrobots)** [#25](https://github.com/nodejs/node-inspect/pull/25)
6+
- [`2a47125`](https://github.com/nodejs/node-inspect/commit/2a4712577f6996fbb078dcfcd7320c397685d76a) **fix:** print 'ok' after connection
7+
* Make autocompletion in REPL work - **[@aqrln](https://github.com/aqrln)** [#28](https://github.com/nodejs/node-inspect/pull/28)
8+
- [`ccab737`](https://github.com/nodejs/node-inspect/commit/ccab737399249a8c2230ed6adfec579c7d724364) **fix:** Make autocompletion in REPL work
9+
* Remove console.error() statement - **[@aqrln](https://github.com/aqrln)** [#30](https://github.com/nodejs/node-inspect/pull/30)
10+
- [`032b045`](https://github.com/nodejs/node-inspect/commit/032b045d4d73622c77b7ebcc26781c6ad98200b3) **style:** Remove console.error() statement
11+
* Take --debug-port into account - **[@jkrems](https://github.com/jkrems)** [#26](https://github.com/nodejs/node-inspect/pull/26)
12+
- [`054d4b1`](https://github.com/nodejs/node-inspect/commit/054d4b10e65f12a3a4b10b4c0ab2a4768cc5e893) **fix:** Take --debug-port into account
13+
* Delay run until breakpoints are restored - **[@jkrems](https://github.com/jkrems)** [#34](https://github.com/nodejs/node-inspect/pull/34)
14+
- [`802b88c`](https://github.com/nodejs/node-inspect/commit/802b88c8ad0a57608cb9e0cb4bf46ed683bb6344) **fix:** Delay run until breakpoints are restored
15+
- [`2b93173`](https://github.com/nodejs/node-inspect/commit/2b93173d95e7f8b30d85603613cb2ae3b3ec18db) **fix:** Use single string for paused notice
16+
- [`b4d5ee2`](https://github.com/nodejs/node-inspect/commit/b4d5ee2a3d25613b35a2e8e10a0eb75582cc5654) **fix:** Work around inconsistent handling of strict directive
17+
- [`f6ccfc7`](https://github.com/nodejs/node-inspect/commit/f6ccfc7f4d00ad4fdf3b581b677f8d7f1699c44c) **fix:** Only restart after port is free
18+
- [`8b101bf`](https://github.com/nodejs/node-inspect/commit/8b101bf669ca102df4980bfad3e0436ef1c2f1a4) **test:** Skip exact match on AIX
19+
* [`a4e4b6f`](https://github.com/nodejs/node-inspect/commit/a4e4b6feeba4dedfd2c89ef32f39e813314d3bbd) **chore:** Fix repo info in package.json
20+
21+
22+
### 1.10.5
23+
24+
* docs: minor edits to governance docs - **[@joshgav](https://github.com/joshgav)** [#17](https://github.com/buggerjs/node-inspect/pull/17)
25+
- [`a70fe04`](https://github.com/buggerjs/node-inspect/commit/a70fe04bdde9b7c74588685066291f9b11183328) **docs:** minor edits to governance docs
26+
27+
128
### 1.10.4
229

330
* [`1c31bf7`](https://github.com/buggerjs/node-inspect/commit/1c31bf7d1b3ea1b424ae0662526596670cb506c9) **chore:** Support embedded mode

deps/node-inspect/CONTRIBUTING.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@
44

55
This document outlines some of the practices we care about.
66
If you have any questions or suggestions about the process,
7-
feel free to [open an issue](#reporting-issues)
8-
.
7+
feel free to [open an issue](#reporting-issues).
98

109
## Code of Conduct
1110

1211
The [Node.js Code of Conduct][] applies to this repo.
1312

1413
[Node.js Code of Conduct]: https://github.com/nodejs/node/blob/master/CODE_OF_CONDUCT.md
1514

16-
## Code Contributions
15+
## Governance
1716

18-
The nodereport project falls under the governance of the diagnostics
19-
working group which is documented in:
20-
https://github.com/nodejs/diagnostics/blob/master/GOVERNANCE.md.
17+
This project falls under the governance of the Node.js Diagnostics WG as
18+
described at <https://github.com/nodejs/diagnostics/blob/master/GOVERNANCE.md>.
2119

2220
## Developer's Certificate of Origin 1.1
2321

@@ -51,7 +49,7 @@ By making a contribution to this project, I certify that:
5149

5250
If you find any mistakes in the docs or a bug in the code,
5351
please [open an issue in Github](https://github.com/nodejs/node-inspect/issues/new) so we can look into it.
54-
You can also [create a PR](#contributing-code) fixing it yourself, or course.
52+
You can also [create a PR](#contributing-code) fixing it yourself of course.
5553

5654
If you report a bug, please follow these guidelines:
5755

@@ -67,7 +65,7 @@ If you report a bug, please follow these guidelines:
6765

6866
For small documentation changes, you can use [Github's editing feature](https://help.github.com/articles/editing-files-in-another-user-s-repository/).
6967
The only thing to keep in mind is to prefix the commit message with "docs: ".
70-
The detault commit message generated by Github will lead to a failing CI build.
68+
The default commit message generated by Github will lead to a failing CI build.
7169

7270
For larger updates to the documentation
7371
it might be better to follow the [instructions for contributing code below](#contributing-code).

deps/node-inspect/GOVERNANCE.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# node-inspect Project Governance
22

3-
The node-inspect project falls under the governance of the diagnostics
4-
working group which is documented in:
5-
https://github.com/nodejs/diagnostics/blob/master/GOVERNANCE.md.
3+
The node-inspect project is governed by the Node.js Diagnostics WG as described
4+
at <https://github.com/nodejs/diagnostics/blob/master/GOVERNANCE.md>.

deps/node-inspect/examples/alive.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
let x = 0;
32
function heartbeat() {
43
++x;

deps/node-inspect/examples/backtrace.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
const { exports: moduleScoped } = module;
32

43
function topFn(a, b = false) {
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
'use strict';
1+
const fourty = 40;
22
const { add } = require('./other');
33

4-
const sum = add(40, 2);
4+
const sum = add(fourty, 2);
55
module.exports = sum;
-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
exports.add = function add(a, b) {
32
return a + b;
43
};

deps/node-inspect/examples/exceptions.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
let error = null;
32
try {
43
throw new Error('Caught');
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
let x = 1;
32
x = x + 1;
43
module.exports = x;
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
'use strict';
2+
console.log('first real line');

deps/node-inspect/lib/_inspect.js

+79-12
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@
2222
'use strict';
2323
const { spawn } = require('child_process');
2424
const { EventEmitter } = require('events');
25+
const net = require('net');
2526
const util = require('util');
2627

28+
const runAsStandalone = typeof __dirname !== 'undefined';
29+
2730
const [ InspectClient, createRepl ] =
28-
(typeof __dirname !== 'undefined') ?
31+
runAsStandalone ?
2932
// This copy of node-inspect is on-disk, relative paths make sense.
3033
[
3134
require('./internal/inspect_client'),
@@ -39,7 +42,16 @@ const [ InspectClient, createRepl ] =
3942

4043
const debuglog = util.debuglog('inspect');
4144

42-
exports.port = 9229;
45+
const DEBUG_PORT_PATTERN = /^--(?:debug|inspect)-port=(\d+)$/;
46+
function getDefaultPort() {
47+
for (const arg of process.execArgv) {
48+
const match = arg.match(DEBUG_PORT_PATTERN);
49+
if (match) {
50+
return +match[1];
51+
}
52+
}
53+
return 9229;
54+
}
4355

4456
function runScript(script, scriptArgs, inspectPort, childPrint) {
4557
return new Promise((resolve) => {
@@ -88,6 +100,45 @@ function createAgentProxy(domain, client) {
88100
});
89101
}
90102

103+
function portIsFree(host, port, timeout = 2000) {
104+
const retryDelay = 150;
105+
let didTimeOut = false;
106+
107+
return new Promise((resolve, reject) => {
108+
setTimeout(() => {
109+
didTimeOut = true;
110+
reject(new Error(
111+
`Timeout (${timeout}) waiting for ${host}:${port} to be free`));
112+
}, timeout);
113+
114+
function pingPort() {
115+
if (didTimeOut) return;
116+
117+
const socket = net.connect(port, host);
118+
let didRetry = false;
119+
function retry() {
120+
if (!didRetry && !didTimeOut) {
121+
didRetry = true;
122+
setTimeout(pingPort, retryDelay);
123+
}
124+
}
125+
126+
socket.on('error', (error) => {
127+
if (error.code === 'ECONNREFUSED') {
128+
resolve();
129+
} else {
130+
retry();
131+
}
132+
});
133+
socket.on('connect', () => {
134+
socket.destroy();
135+
retry();
136+
});
137+
}
138+
pingPort();
139+
});
140+
}
141+
91142
class NodeInspector {
92143
constructor(options, stdin, stdout) {
93144
this.options = options;
@@ -128,8 +179,9 @@ class NodeInspector {
128179
process.once('SIGHUP', process.exit.bind(process, 0));
129180

130181
this.run()
131-
.then(() => {
132-
this.repl = startRepl();
182+
.then(() => startRepl())
183+
.then((repl) => {
184+
this.repl = repl;
133185
this.repl.on('exit', () => {
134186
process.exit(0);
135187
});
@@ -139,15 +191,19 @@ class NodeInspector {
139191
}
140192

141193
suspendReplWhile(fn) {
142-
this.repl.rli.pause();
194+
if (this.repl) {
195+
this.repl.rli.pause();
196+
}
143197
this.stdin.pause();
144198
this.paused = true;
145199
return new Promise((resolve) => {
146200
resolve(fn());
147201
}).then(() => {
148202
this.paused = false;
149-
this.repl.rli.resume();
150-
this.repl.displayPrompt();
203+
if (this.repl) {
204+
this.repl.rli.resume();
205+
this.repl.displayPrompt();
206+
}
151207
this.stdin.resume();
152208
}).then(null, (error) => process.nextTick(() => { throw error; }));
153209
}
@@ -162,7 +218,14 @@ class NodeInspector {
162218

163219
run() {
164220
this.killChild();
165-
return this._runScript().then((child) => {
221+
const { host, port } = this.options;
222+
223+
const runOncePortIsFree = () => {
224+
return portIsFree(host, port)
225+
.then(() => this._runScript());
226+
};
227+
228+
return runOncePortIsFree().then((child) => {
166229
this.child = child;
167230

168231
let connectionAttempts = 0;
@@ -173,6 +236,7 @@ class NodeInspector {
173236
return this.client.connect()
174237
.then(() => {
175238
debuglog('connection established');
239+
this.stdout.write(' ok');
176240
}, (error) => {
177241
debuglog('connect failed', error);
178242
// If it's failed to connect 10 times then print failed message
@@ -186,7 +250,6 @@ class NodeInspector {
186250
});
187251
};
188252

189-
const { host, port } = this.options;
190253
this.print(`connecting to ${host}:${port} ..`, true);
191254
return attemptConnect();
192255
});
@@ -225,7 +288,7 @@ class NodeInspector {
225288

226289
function parseArgv([target, ...args]) {
227290
let host = '127.0.0.1';
228-
let port = exports.port;
291+
let port = getDefaultPort();
229292
let isRemote = false;
230293
let script = target;
231294
let scriptArgs = args;
@@ -258,8 +321,12 @@ function startInspect(argv = process.argv.slice(2),
258321
stdout = process.stdout) {
259322
/* eslint-disable no-console */
260323
if (argv.length < 1) {
261-
console.error('Usage: node-inspect script.js');
262-
console.error(' node-inspect <host>:<port>');
324+
const invokedAs = runAsStandalone ?
325+
'node-inspect' :
326+
`${process.argv0} ${process.argv[1]}`;
327+
328+
console.error(`Usage: ${invokedAs} script.js`);
329+
console.error(` ${invokedAs} <host>:<port>`);
263330
process.exit(1);
264331
}
265332

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

+1-14
Original file line numberDiff line numberDiff line change
@@ -334,20 +334,7 @@ class Client extends EventEmitter {
334334
this.emit('close');
335335
});
336336

337-
Promise.all([
338-
this.callMethod('Runtime.enable'),
339-
this.callMethod('Debugger.enable'),
340-
this.callMethod('Debugger.setPauseOnExceptions', { state: 'none' }),
341-
this.callMethod('Debugger.setAsyncCallStackDepth', { maxDepth: 0 }),
342-
this.callMethod('Profiler.enable'),
343-
this.callMethod('Profiler.setSamplingInterval', { interval: 100 }),
344-
this.callMethod('Debugger.setBlackboxPatterns', { patterns: [] }),
345-
this.callMethod('Runtime.runIfWaitingForDebugger'),
346-
]).then(() => {
347-
this.emit('ready');
348-
}, (error) => {
349-
this.emit('error', error);
350-
});
337+
this.emit('ready');
351338
};
352339

353340
return new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)