summaryrefslogtreecommitdiff
path: root/deps/node-inspect
diff options
context:
space:
mode:
authorJan Krems <jan.krems@groupon.com>2018-01-24 10:42:54 -0800
committerRuben Bridgewater <ruben@bridgewater.de>2018-02-01 13:39:40 +0100
commit02b3bbc5e20e0d663c9e16d1617d78af10950905 (patch)
tree3a5a145e1190b646f3ce7bb8c1f2c8c34f5383f5 /deps/node-inspect
parent7ff4888ed2d99a7ea412b3dee46286a8754956c4 (diff)
downloadandroid-node-v8-02b3bbc5e20e0d663c9e16d1617d78af10950905.tar.gz
android-node-v8-02b3bbc5e20e0d663c9e16d1617d78af10950905.tar.bz2
android-node-v8-02b3bbc5e20e0d663c9e16d1617d78af10950905.zip
deps: update node-inspect to 1.11.3
Highlights: * Using a random port works (`node inspect --port=0 script.js`) * `takeHeapSnapshot()` creates valid snapshots again PR-URL: https://github.com/nodejs/node/pull/18354 Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'deps/node-inspect')
-rw-r--r--deps/node-inspect/CHANGELOG.md9
-rw-r--r--deps/node-inspect/README.md2
-rw-r--r--deps/node-inspect/lib/_inspect.js31
-rw-r--r--deps/node-inspect/lib/internal/inspect_client.js10
-rw-r--r--deps/node-inspect/lib/internal/inspect_repl.js20
-rw-r--r--deps/node-inspect/package.json4
-rw-r--r--deps/node-inspect/test/cli/break.test.js4
-rw-r--r--deps/node-inspect/test/cli/heap-profiler.test.js34
-rw-r--r--deps/node-inspect/test/cli/launch.test.js40
-rw-r--r--deps/node-inspect/test/cli/start-cli.js4
10 files changed, 118 insertions, 40 deletions
diff --git a/deps/node-inspect/CHANGELOG.md b/deps/node-inspect/CHANGELOG.md
index 41ed928e78..0db3a7842e 100644
--- a/deps/node-inspect/CHANGELOG.md
+++ b/deps/node-inspect/CHANGELOG.md
@@ -1,3 +1,12 @@
+### 1.11.3
+
+* [`93caa0f`](https://github.com/nodejs/node-inspect/commit/93caa0f5267c7ab452b258d3b03329a0bb5ac7f7) **docs:** Add missing oc in protocol
+* [`2d87cbe`](https://github.com/nodejs/node-inspect/commit/2d87cbe76aa968dfc1ac69d9571af1be81abd8e0) **fix:** Make --inspect-port=0 work
+* [`ebfd02e`](https://github.com/nodejs/node-inspect/commit/ebfd02ece9b642586023f7791da71defeb13d746) **chore:** Bump tap to 10.7
+* [`c07adb1`](https://github.com/nodejs/node-inspect/commit/c07adb17b164c1cf3da8d38659ea9f5d7ff42e9c) **test:** Use useful break location
+* [`94f0bf9`](https://github.com/nodejs/node-inspect/commit/94f0bf97d24c376baf3ecced2088d81715a73464) **fix:** Fix `takeHeapSnapshot()` truncation bug
+
+
### 1.11.2
* [`42e0cd1`](https://github.com/nodejs/node-inspect/commit/42e0cd111d89ed09faba1c0ec45089b0b44de011) **fix:** look for generic hint text
diff --git a/deps/node-inspect/README.md b/deps/node-inspect/README.md
index ecd939b3ea..b52cc188a6 100644
--- a/deps/node-inspect/README.md
+++ b/deps/node-inspect/README.md
@@ -10,7 +10,7 @@ node has two options:
1. `node --debug <file>`: Start `file` with remote debugging enabled.
2. `node debug <file>`: Start an interactive CLI debugger for `<file>`.
-But for the Chrome inspector protol,
+But for the Chrome inspector protocol,
there's only one: `node --inspect <file>`.
This project tries to provide the missing second option
diff --git a/deps/node-inspect/lib/_inspect.js b/deps/node-inspect/lib/_inspect.js
index 26912274cd..d846efbe6a 100644
--- a/deps/node-inspect/lib/_inspect.js
+++ b/deps/node-inspect/lib/_inspect.js
@@ -42,18 +42,9 @@ const [ InspectClient, createRepl ] =
const debuglog = util.debuglog('inspect');
-const DEBUG_PORT_PATTERN = /^--(?:debug|inspect)(?:-port|-brk)?=(\d{1,5})$/;
-function getDefaultPort() {
- for (const arg of process.execArgv) {
- const match = arg.match(DEBUG_PORT_PATTERN);
- if (match) {
- return +match[1];
- }
- }
- return 9229;
-}
-
function portIsFree(host, port, timeout = 2000) {
+ if (port === 0) return Promise.resolve(); // Binding to a random port.
+
const retryDelay = 150;
let didTimeOut = false;
@@ -110,9 +101,11 @@ function runScript(script, scriptArgs, inspectHost, inspectPort, childPrint) {
let output = '';
function waitForListenHint(text) {
output += text;
- if (/Debugger listening on/.test(output)) {
+ if (/Debugger listening on ws:\/\/\[?(.+?)\]?:(\d+)\//.test(output)) {
+ const host = RegExp.$1;
+ const port = Number.parseInt(RegExp.$2);
child.stderr.removeListener('data', waitForListenHint);
- resolve(child);
+ resolve([child, port, host]);
}
}
@@ -160,10 +153,11 @@ class NodeInspector {
options.port,
this.childPrint.bind(this));
} else {
- this._runScript = () => Promise.resolve(null);
+ this._runScript =
+ () => Promise.resolve([null, options.port, options.host]);
}
- this.client = new InspectClient(options.port, options.host);
+ this.client = new InspectClient();
this.domainNames = ['Debugger', 'HeapProfiler', 'Profiler', 'Runtime'];
this.domainNames.forEach((domain) => {
@@ -223,9 +217,8 @@ class NodeInspector {
run() {
this.killChild();
- const { host, port } = this.options;
- return this._runScript().then((child) => {
+ return this._runScript().then(([child, port, host]) => {
this.child = child;
let connectionAttempts = 0;
@@ -233,7 +226,7 @@ class NodeInspector {
++connectionAttempts;
debuglog('connection attempt #%d', connectionAttempts);
this.stdout.write('.');
- return this.client.connect()
+ return this.client.connect(port, host)
.then(() => {
debuglog('connection established');
this.stdout.write(' ok');
@@ -288,7 +281,7 @@ class NodeInspector {
function parseArgv([target, ...args]) {
let host = '127.0.0.1';
- let port = getDefaultPort();
+ let port = 9229;
let isRemote = false;
let script = target;
let scriptArgs = args;
diff --git a/deps/node-inspect/lib/internal/inspect_client.js b/deps/node-inspect/lib/internal/inspect_client.js
index c247e2add8..9b8529de21 100644
--- a/deps/node-inspect/lib/internal/inspect_client.js
+++ b/deps/node-inspect/lib/internal/inspect_client.js
@@ -164,12 +164,12 @@ function decodeFrameHybi17(data) {
}
class Client extends EventEmitter {
- constructor(port, host) {
+ constructor() {
super();
this.handleChunk = this._handleChunk.bind(this);
- this._port = port;
- this._host = host;
+ this._port = undefined;
+ this._host = undefined;
this.reset();
}
@@ -284,7 +284,9 @@ class Client extends EventEmitter {
});
}
- connect() {
+ connect(port, host) {
+ this._port = port;
+ this._host = host;
return this._discoverWebsocketPath()
.then((urlPath) => this._connectWebsocket(urlPath));
}
diff --git a/deps/node-inspect/lib/internal/inspect_repl.js b/deps/node-inspect/lib/internal/inspect_repl.js
index 937c1843d3..38fe4684cf 100644
--- a/deps/node-inspect/lib/internal/inspect_repl.js
+++ b/deps/node-inspect/lib/internal/inspect_repl.js
@@ -900,10 +900,8 @@ function createRepl(inspector) {
return new Promise((resolve, reject) => {
const absoluteFile = Path.resolve(filename);
const writer = FS.createWriteStream(absoluteFile);
- let totalSize;
let sizeWritten = 0;
function onProgress({ done, total, finished }) {
- totalSize = total;
if (finished) {
print('Heap snaphost prepared.');
} else {
@@ -913,13 +911,18 @@ function createRepl(inspector) {
function onChunk({ chunk }) {
sizeWritten += chunk.length;
writer.write(chunk);
- print(`Writing snapshot: ${sizeWritten}/${totalSize}`, true);
- if (sizeWritten >= totalSize) {
- writer.end();
+ print(`Writing snapshot: ${sizeWritten}`, true);
+ }
+ function onResolve() {
+ writer.end(() => {
teardown();
print(`Wrote snapshot: ${absoluteFile}`);
resolve();
- }
+ });
+ }
+ function onReject(error) {
+ teardown();
+ reject(error);
}
function teardown() {
HeapProfiler.removeListener(
@@ -932,10 +935,7 @@ function createRepl(inspector) {
print('Heap snapshot: 0/0', true);
HeapProfiler.takeHeapSnapshot({ reportProgress: true })
- .then(null, (error) => {
- teardown();
- reject(error);
- });
+ .then(onResolve, onReject);
});
},
diff --git a/deps/node-inspect/package.json b/deps/node-inspect/package.json
index 070abfa8fe..d25376b5d4 100644
--- a/deps/node-inspect/package.json
+++ b/deps/node-inspect/package.json
@@ -1,6 +1,6 @@
{
"name": "node-inspect",
- "version": "1.11.2",
+ "version": "1.11.3",
"description": "Node Inspect",
"license": "MIT",
"main": "lib/_inspect.js",
@@ -29,7 +29,7 @@
"devDependencies": {
"eslint": "^3.10.2",
"nlm": "^3.0.0",
- "tap": "^7.1.2"
+ "tap": "^10.7.0"
},
"author": {
"name": "Jan Krems",
diff --git a/deps/node-inspect/test/cli/break.test.js b/deps/node-inspect/test/cli/break.test.js
index 59b12cde38..ce8c8d6d7d 100644
--- a/deps/node-inspect/test/cli/break.test.js
+++ b/deps/node-inspect/test/cli/break.test.js
@@ -134,7 +134,7 @@ test('sb before loading file', (t) => {
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
- .then(() => cli.command('sb("other.js", 3)'))
+ .then(() => cli.command('sb("other.js", 2)'))
.then(() => {
t.match(
cli.output,
@@ -145,7 +145,7 @@ test('sb before loading file', (t) => {
.then(() => {
t.match(
cli.output,
- `break in ${otherScript}:3`,
+ `break in ${otherScript}:2`,
'found breakpoint in file that was not loaded yet');
})
.then(() => cli.quit())
diff --git a/deps/node-inspect/test/cli/heap-profiler.test.js b/deps/node-inspect/test/cli/heap-profiler.test.js
new file mode 100644
index 0000000000..ebd734e03c
--- /dev/null
+++ b/deps/node-inspect/test/cli/heap-profiler.test.js
@@ -0,0 +1,34 @@
+'use strict';
+const { test } = require('tap');
+const { readFileSync, unlinkSync } = require('fs');
+
+const startCLI = require('./start-cli');
+const filename = 'node.heapsnapshot';
+
+function cleanup() {
+ try {
+ unlinkSync(filename);
+ } catch (_) {
+ // Ignore.
+ }
+}
+
+cleanup();
+
+test('Heap profiler take snapshot', (t) => {
+ const cli = startCLI(['examples/empty.js']);
+
+ function onFatal(error) {
+ cli.quit();
+ throw error;
+ }
+
+ // Check that the snapshot is valid JSON.
+ return cli.waitForInitialBreak()
+ .then(() => cli.waitForPrompt())
+ .then(() => cli.command('takeHeapSnapshot()'))
+ .then(() => JSON.parse(readFileSync(filename, 'utf8')))
+ .then(() => cleanup())
+ .then(() => cli.quit())
+ .then(null, onFatal);
+});
diff --git a/deps/node-inspect/test/cli/launch.test.js b/deps/node-inspect/test/cli/launch.test.js
index f7efc6eb3f..8808d47a08 100644
--- a/deps/node-inspect/test/cli/launch.test.js
+++ b/deps/node-inspect/test/cli/launch.test.js
@@ -26,6 +26,46 @@ test('custom port', (t) => {
});
});
+test('random port', (t) => {
+ const script = Path.join('examples', 'three-lines.js');
+
+ const cli = startCLI(['--port=0', script]);
+
+ return cli.waitForInitialBreak()
+ .then(() => cli.waitForPrompt())
+ .then(() => {
+ t.match(cli.output, 'debug>', 'prints a prompt');
+ t.match(
+ cli.output,
+ /< Debugger listening on /,
+ 'forwards child output');
+ })
+ .then(() => cli.quit())
+ .then((code) => {
+ t.equal(code, 0, 'exits with success');
+ });
+});
+
+test('random port with --inspect-port=0', (t) => {
+ const script = Path.join('examples', 'three-lines.js');
+
+ const cli = startCLI([script], ['--inspect-port=0']);
+
+ return cli.waitForInitialBreak()
+ .then(() => cli.waitForPrompt())
+ .then(() => {
+ t.match(cli.output, 'debug>', 'prints a prompt');
+ t.match(
+ cli.output,
+ /< Debugger listening on /,
+ 'forwards child output');
+ })
+ .then(() => cli.quit())
+ .then((code) => {
+ t.equal(code, 0, 'exits with success');
+ });
+});
+
test('examples/three-lines.js', (t) => {
const script = Path.join('examples', 'three-lines.js');
const cli = startCLI([script]);
diff --git a/deps/node-inspect/test/cli/start-cli.js b/deps/node-inspect/test/cli/start-cli.js
index ae904308e0..b086dcd8ba 100644
--- a/deps/node-inspect/test/cli/start-cli.js
+++ b/deps/node-inspect/test/cli/start-cli.js
@@ -16,8 +16,8 @@ const BREAK_MESSAGE = new RegExp('(?:' + [
'exception', 'other', 'promiseRejection',
].join('|') + ') in', 'i');
-function startCLI(args) {
- const child = spawn(process.execPath, [CLI, ...args]);
+function startCLI(args, flags = []) {
+ const child = spawn(process.execPath, [...flags, CLI, ...args]);
let isFirstStdoutChunk = true;
const outputBuffer = [];