Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: Add node-inspect 1.10.6 #11869

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions deps/node-inspect/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
### 1.10.6

* chore: Fix usage text for embedded mode - **[@addaleax](https://github.com/addaleax)** [#20](https://github.com/nodejs/node-inspect/pull/20)
- [`b0779f5`](https://github.com/nodejs/node-inspect/commit/b0779f597104e9ada5681f64d7e714525b753511) **chore:** Fix usage text for embedded mode
* print 'ok' after connection - **[@ofrobots](https://github.com/ofrobots)** [#25](https://github.com/nodejs/node-inspect/pull/25)
- [`2a47125`](https://github.com/nodejs/node-inspect/commit/2a4712577f6996fbb078dcfcd7320c397685d76a) **fix:** print 'ok' after connection
* Make autocompletion in REPL work - **[@aqrln](https://github.com/aqrln)** [#28](https://github.com/nodejs/node-inspect/pull/28)
- [`ccab737`](https://github.com/nodejs/node-inspect/commit/ccab737399249a8c2230ed6adfec579c7d724364) **fix:** Make autocompletion in REPL work
* Remove console.error() statement - **[@aqrln](https://github.com/aqrln)** [#30](https://github.com/nodejs/node-inspect/pull/30)
- [`032b045`](https://github.com/nodejs/node-inspect/commit/032b045d4d73622c77b7ebcc26781c6ad98200b3) **style:** Remove console.error() statement
* Take --debug-port into account - **[@jkrems](https://github.com/jkrems)** [#26](https://github.com/nodejs/node-inspect/pull/26)
- [`054d4b1`](https://github.com/nodejs/node-inspect/commit/054d4b10e65f12a3a4b10b4c0ab2a4768cc5e893) **fix:** Take --debug-port into account
* Delay run until breakpoints are restored - **[@jkrems](https://github.com/jkrems)** [#34](https://github.com/nodejs/node-inspect/pull/34)
- [`802b88c`](https://github.com/nodejs/node-inspect/commit/802b88c8ad0a57608cb9e0cb4bf46ed683bb6344) **fix:** Delay run until breakpoints are restored
- [`2b93173`](https://github.com/nodejs/node-inspect/commit/2b93173d95e7f8b30d85603613cb2ae3b3ec18db) **fix:** Use single string for paused notice
- [`b4d5ee2`](https://github.com/nodejs/node-inspect/commit/b4d5ee2a3d25613b35a2e8e10a0eb75582cc5654) **fix:** Work around inconsistent handling of strict directive
- [`f6ccfc7`](https://github.com/nodejs/node-inspect/commit/f6ccfc7f4d00ad4fdf3b581b677f8d7f1699c44c) **fix:** Only restart after port is free
- [`8b101bf`](https://github.com/nodejs/node-inspect/commit/8b101bf669ca102df4980bfad3e0436ef1c2f1a4) **test:** Skip exact match on AIX
* [`a4e4b6f`](https://github.com/nodejs/node-inspect/commit/a4e4b6feeba4dedfd2c89ef32f39e813314d3bbd) **chore:** Fix repo info in package.json


### 1.10.5

* docs: minor edits to governance docs - **[@joshgav](https://github.com/joshgav)** [#17](https://github.com/buggerjs/node-inspect/pull/17)
- [`a70fe04`](https://github.com/buggerjs/node-inspect/commit/a70fe04bdde9b7c74588685066291f9b11183328) **docs:** minor edits to governance docs


### 1.10.4

* [`1c31bf7`](https://github.com/buggerjs/node-inspect/commit/1c31bf7d1b3ea1b424ae0662526596670cb506c9) **chore:** Support embedded mode
Expand Down
15 changes: 7 additions & 8 deletions deps/node-inspect/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@

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

## Code of Conduct

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

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

## Code Contributions
## Governance

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

## Developer's Certificate of Origin 1.1

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

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

If you report a bug, please follow these guidelines:

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

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

For larger updates to the documentation
it might be better to follow the [instructions for contributing code below](#contributing-code).
Expand Down Expand Up @@ -181,3 +179,4 @@ A simple bug fix:
```
fix: Handle multi-byte characters in search logic
```

5 changes: 2 additions & 3 deletions deps/node-inspect/GOVERNANCE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# node-inspect Project Governance

The node-inspect project falls under the governance of the diagnostics
working group which is documented in:
https://github.com/nodejs/diagnostics/blob/master/GOVERNANCE.md.
The node-inspect project is governed by the Node.js Diagnostics WG as described
at <https://github.com/nodejs/diagnostics/blob/master/GOVERNANCE.md>.
1 change: 0 additions & 1 deletion deps/node-inspect/examples/alive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
'use strict';
let x = 0;
function heartbeat() {
++x;
Expand Down
1 change: 0 additions & 1 deletion deps/node-inspect/examples/backtrace.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
'use strict';
const { exports: moduleScoped } = module;

function topFn(a, b = false) {
Expand Down
4 changes: 2 additions & 2 deletions deps/node-inspect/examples/cjs/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const fourty = 40;
const { add } = require('./other');

const sum = add(40, 2);
const sum = add(fourty, 2);
module.exports = sum;
1 change: 0 additions & 1 deletion deps/node-inspect/examples/cjs/other.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
'use strict';
exports.add = function add(a, b) {
return a + b;
};
1 change: 0 additions & 1 deletion deps/node-inspect/examples/exceptions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
'use strict';
let error = null;
try {
throw new Error('Caught');
Expand Down
1 change: 0 additions & 1 deletion deps/node-inspect/examples/three-lines.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
'use strict';
let x = 1;
x = x + 1;
module.exports = x;
2 changes: 2 additions & 0 deletions deps/node-inspect/examples/use-strict.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict';
console.log('first real line');
91 changes: 79 additions & 12 deletions deps/node-inspect/lib/_inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
'use strict';
const { spawn } = require('child_process');
const { EventEmitter } = require('events');
const net = require('net');
const util = require('util');

const runAsStandalone = typeof __dirname !== 'undefined';

const [ InspectClient, createRepl ] =
(typeof __dirname !== 'undefined') ?
runAsStandalone ?
// This copy of node-inspect is on-disk, relative paths make sense.
[
require('./internal/inspect_client'),
Expand All @@ -39,7 +42,16 @@ const [ InspectClient, createRepl ] =

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

exports.port = 9229;
const DEBUG_PORT_PATTERN = /^--(?:debug|inspect)-port=(\d+)$/;
function getDefaultPort() {
for (const arg of process.execArgv) {
const match = arg.match(DEBUG_PORT_PATTERN);
if (match) {
return +match[1];
}
}
return 9229;
}

function runScript(script, scriptArgs, inspectPort, childPrint) {
return new Promise((resolve) => {
Expand Down Expand Up @@ -88,6 +100,45 @@ function createAgentProxy(domain, client) {
});
}

function portIsFree(host, port, timeout = 2000) {
const retryDelay = 150;
let didTimeOut = false;

return new Promise((resolve, reject) => {
setTimeout(() => {
didTimeOut = true;
reject(new Error(
`Timeout (${timeout}) waiting for ${host}:${port} to be free`));
}, timeout);

function pingPort() {
if (didTimeOut) return;

const socket = net.connect(port, host);
let didRetry = false;
function retry() {
if (!didRetry && !didTimeOut) {
didRetry = true;
setTimeout(pingPort, retryDelay);
}
}

socket.on('error', (error) => {
if (error.code === 'ECONNREFUSED') {
resolve();
} else {
retry();
}
});
socket.on('connect', () => {
socket.destroy();
retry();
});
}
pingPort();
});
}

class NodeInspector {
constructor(options, stdin, stdout) {
this.options = options;
Expand Down Expand Up @@ -128,8 +179,9 @@ class NodeInspector {
process.once('SIGHUP', process.exit.bind(process, 0));

this.run()
.then(() => {
this.repl = startRepl();
.then(() => startRepl())
.then((repl) => {
this.repl = repl;
this.repl.on('exit', () => {
process.exit(0);
});
Expand All @@ -139,15 +191,19 @@ class NodeInspector {
}

suspendReplWhile(fn) {
this.repl.rli.pause();
if (this.repl) {
this.repl.rli.pause();
}
this.stdin.pause();
this.paused = true;
return new Promise((resolve) => {
resolve(fn());
}).then(() => {
this.paused = false;
this.repl.rli.resume();
this.repl.displayPrompt();
if (this.repl) {
this.repl.rli.resume();
this.repl.displayPrompt();
}
this.stdin.resume();
}).then(null, (error) => process.nextTick(() => { throw error; }));
}
Expand All @@ -162,7 +218,14 @@ class NodeInspector {

run() {
this.killChild();
return this._runScript().then((child) => {
const { host, port } = this.options;

const runOncePortIsFree = () => {
return portIsFree(host, port)
.then(() => this._runScript());
};

return runOncePortIsFree().then((child) => {
this.child = child;

let connectionAttempts = 0;
Expand All @@ -173,6 +236,7 @@ class NodeInspector {
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
Expand All @@ -186,7 +250,6 @@ class NodeInspector {
});
};

const { host, port } = this.options;
this.print(`connecting to ${host}:${port} ..`, true);
return attemptConnect();
});
Expand Down Expand Up @@ -225,7 +288,7 @@ class NodeInspector {

function parseArgv([target, ...args]) {
let host = '127.0.0.1';
let port = exports.port;
let port = getDefaultPort();
let isRemote = false;
let script = target;
let scriptArgs = args;
Expand Down Expand Up @@ -258,8 +321,12 @@ function startInspect(argv = process.argv.slice(2),
stdout = process.stdout) {
/* eslint-disable no-console */
if (argv.length < 1) {
console.error('Usage: node-inspect script.js');
console.error(' node-inspect <host>:<port>');
const invokedAs = runAsStandalone ?
'node-inspect' :
`${process.argv0} ${process.argv[1]}`;

console.error(`Usage: ${invokedAs} script.js`);
console.error(` ${invokedAs} <host>:<port>`);
process.exit(1);
}

Expand Down
15 changes: 1 addition & 14 deletions deps/node-inspect/lib/internal/inspect_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,20 +334,7 @@ class Client extends EventEmitter {
this.emit('close');
});

Promise.all([
this.callMethod('Runtime.enable'),
this.callMethod('Debugger.enable'),
this.callMethod('Debugger.setPauseOnExceptions', { state: 'none' }),
this.callMethod('Debugger.setAsyncCallStackDepth', { maxDepth: 0 }),
this.callMethod('Profiler.enable'),
this.callMethod('Profiler.setSamplingInterval', { interval: 100 }),
this.callMethod('Debugger.setBlackboxPatterns', { patterns: [] }),
this.callMethod('Runtime.runIfWaitingForDebugger'),
]).then(() => {
this.emit('ready');
}, (error) => {
this.emit('error', error);
});
this.emit('ready');
};

return new Promise((resolve, reject) => {
Expand Down
Loading