summaryrefslogtreecommitdiff
path: root/deps/node-inspect/lib/_inspect.js
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/lib/_inspect.js
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/lib/_inspect.js')
-rw-r--r--deps/node-inspect/lib/_inspect.js31
1 files changed, 12 insertions, 19 deletions
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;