Skip to content

Commit d42ad64

Browse files
Jan KremsBridgeAR
Jan Krems
authored andcommitted
deps: update node-inspect to v1.11.6
Highlights: * The `node-inspect` test suite passes against latest master. * Removes use of deprecated `repl.rli`. Compare: nodejs/node-inspect@v1.11.5...v1.11.6 PR-URL: #28039 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent e3f905a commit d42ad64

12 files changed

+79
-45
lines changed

deps/node-inspect/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
### 1.11.6
2+
3+
* fix: replace the deprecated "repl.cli" with "repl" - **[@oyyd](https://github.com./oyyd)** [#66](https://github.com./nodejs/node-inspect/pull/66)
4+
- [`5c1d771`](https://github.com./nodejs/node-inspect/commit/5c1d7716523b73e26f98f4f594ee34b7daa920a0) **fix:** replace the deprecated "repl.cli" with "repl" - see: [26260](Refs: https://github.com./nodejs/node/pull/26260)
5+
* Address regressions due to changes in node - **[@jkrems](https://github.com./jkrems)** [#67](https://github.com./nodejs/node-inspect/pull/67)
6+
- [`5b3511e`](https://github.com./nodejs/node-inspect/commit/5b3511ef21d0eba8304d8b2fed33f33aae22f308) **fix:** Address regressions due to changes in node
7+
8+
19
### 1.11.5
210

311
* Fix eslint issues - **[@jkrems](https://github.com./jkrems)** [#63](https://github.com./nodejs/node-inspect/pull/63)

deps/node-inspect/lib/_inspect.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class NodeInspector {
198198

199199
suspendReplWhile(fn) {
200200
if (this.repl) {
201-
this.repl.rli.pause();
201+
this.repl.pause();
202202
}
203203
this.stdin.pause();
204204
this.paused = true;
@@ -207,7 +207,7 @@ class NodeInspector {
207207
}).then(() => {
208208
this.paused = false;
209209
if (this.repl) {
210-
this.repl.rli.resume();
210+
this.repl.resume();
211211
this.repl.displayPrompt();
212212
}
213213
this.stdin.resume();

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

+17-13
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const Path = require('path');
2525
const Repl = require('repl');
2626
const util = require('util');
2727
const vm = require('vm');
28+
const fileURLToPath = require('url').fileURLToPath;
2829

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

@@ -89,9 +90,12 @@ function isNativeUrl(url) {
8990
return url.replace('.js', '') in NATIVES || url === 'bootstrap_node.js';
9091
}
9192

92-
function getRelativePath(filename) {
93+
function getRelativePath(filenameOrURL) {
9394
const dir = Path.join(Path.resolve(), 'x').slice(0, -1);
9495

96+
const filename = filenameOrURL.startsWith('file://') ?
97+
fileURLToPath(filenameOrURL) : filenameOrURL;
98+
9599
// Change path to relative, if possible
96100
if (filename.indexOf(dir) === 0) {
97101
return filename.slice(dir.length);
@@ -958,38 +962,38 @@ function createRepl(inspector) {
958962

959963
get repl() {
960964
// Don't display any default messages
961-
const listeners = repl.rli.listeners('SIGINT').slice(0);
962-
repl.rli.removeAllListeners('SIGINT');
965+
const listeners = repl.listeners('SIGINT').slice(0);
966+
repl.removeAllListeners('SIGINT');
963967

964968
const oldContext = repl.context;
965969

966970
exitDebugRepl = () => {
967971
// Restore all listeners
968972
process.nextTick(() => {
969973
listeners.forEach((listener) => {
970-
repl.rli.on('SIGINT', listener);
974+
repl.on('SIGINT', listener);
971975
});
972976
});
973977

974978
// Exit debug repl
975979
repl.eval = controlEval;
976980

977981
// Swap history
978-
history.debug = repl.rli.history;
979-
repl.rli.history = history.control;
982+
history.debug = repl.history;
983+
repl.history = history.control;
980984

981985
repl.context = oldContext;
982-
repl.rli.setPrompt('debug> ');
986+
repl.setPrompt('debug> ');
983987
repl.displayPrompt();
984988

985-
repl.rli.removeListener('SIGINT', exitDebugRepl);
989+
repl.removeListener('SIGINT', exitDebugRepl);
986990
repl.removeListener('exit', exitDebugRepl);
987991

988992
exitDebugRepl = null;
989993
};
990994

991995
// Exit debug repl on SIGINT
992-
repl.rli.on('SIGINT', exitDebugRepl);
996+
repl.on('SIGINT', exitDebugRepl);
993997

994998
// Exit debug repl on repl exit
995999
repl.on('exit', exitDebugRepl);
@@ -999,10 +1003,10 @@ function createRepl(inspector) {
9991003
repl.context = {};
10001004

10011005
// Swap history
1002-
history.control = repl.rli.history;
1003-
repl.rli.history = history.debug;
1006+
history.control = repl.history;
1007+
repl.history = history.debug;
10041008

1005-
repl.rli.setPrompt('> ');
1009+
repl.setPrompt('> ');
10061010

10071011
print('Press Ctrl + C to leave debug repl');
10081012
repl.displayPrompt();
@@ -1077,7 +1081,7 @@ function createRepl(inspector) {
10771081

10781082
repl.defineCommand('interrupt', () => {
10791083
// We want this for testing purposes where sending CTRL-C can be tricky.
1080-
repl.rli.emit('SIGINT');
1084+
repl.emit('SIGINT');
10811085
});
10821086

10831087
// Init once for the initial connection

deps/node-inspect/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-inspect",
3-
"version": "1.11.5",
3+
"version": "1.11.6",
44
"description": "Node Inspect",
55
"license": "MIT",
66
"main": "lib/_inspect.js",

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ test('stepping through breakpoints', (t) => {
1818
.then(() => cli.waitForPrompt())
1919
.then(() => {
2020
t.match(
21-
cli.output,
22-
`break in ${script}:1`,
21+
cli.breakInfo,
22+
{ filename: script, line: 1 },
2323
'pauses in the first line of the script');
2424
t.match(
2525
cli.output,
26-
/> 1 \(function \([^)]+\) \{ const x = 10;/,
26+
/> 1 (?:\(function \([^)]+\) \{ )?const x = 10;/,
2727
'shows the source and marks the current line');
2828
})
2929
.then(() => cli.stepCommand('n'))

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test('break on (uncaught) exceptions', (t) => {
1717
return cli.waitForInitialBreak()
1818
.then(() => cli.waitForPrompt())
1919
.then(() => {
20-
t.match(cli.output, `break in ${script}:1`);
20+
t.match(cli.breakInfo, { filename: script, line: 1 });
2121
})
2222
// making sure it will die by default:
2323
.then(() => cli.command('c'))
@@ -28,7 +28,7 @@ test('break on (uncaught) exceptions', (t) => {
2828
.then(() => cli.stepCommand('r'))
2929
.then(() => cli.waitForInitialBreak())
3030
.then(() => {
31-
t.match(cli.output, `break in ${script}:1`);
31+
t.match(cli.breakInfo, { filename: script, line: 1 });
3232
})
3333
.then(() => cli.command('breakOnException'))
3434
.then(() => cli.stepCommand('c'))
@@ -45,7 +45,7 @@ test('break on (uncaught) exceptions', (t) => {
4545
.then(() => cli.stepCommand('r')) // also, the setting survives the restart
4646
.then(() => cli.waitForInitialBreak())
4747
.then(() => {
48-
t.match(cli.output, `break in ${script}:1`);
48+
t.match(cli.breakInfo, { filename: script, line: 1 });
4949
})
5050
.then(() => cli.stepCommand('c'))
5151
.then(() => {
@@ -57,7 +57,7 @@ test('break on (uncaught) exceptions', (t) => {
5757
.then(() => cli.stepCommand('r'))
5858
.then(() => cli.waitForInitialBreak())
5959
.then(() => {
60-
t.match(cli.output, `break in ${script}:1`);
60+
t.match(cli.breakInfo, { filename: script, line: 1 });
6161
})
6262
.then(() => cli.command('c'))
6363
// TODO: Remove FATAL ERROR once node doesn't show a FATAL ERROR anymore

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -137,23 +137,23 @@ test('run after quit / restart', (t) => {
137137
.then(() => cli.waitForPrompt())
138138
.then(() => {
139139
t.match(
140-
cli.output,
141-
`break in ${script}:1`,
140+
cli.breakInfo,
141+
{ filename: script, line: 1 },
142142
'is back at the beginning');
143143
})
144144
.then(() => cli.stepCommand('n'))
145145
.then(() => {
146146
t.match(
147-
cli.output,
148-
`break in ${script}:2`,
147+
cli.breakInfo,
148+
{ filename: script, line: 2 },
149149
'steps to the 2nd line');
150150
})
151151
.then(() => cli.stepCommand('restart'))
152152
.then(() => cli.waitForInitialBreak())
153153
.then(() => {
154154
t.match(
155-
cli.output,
156-
`break in ${script}:1`,
155+
cli.breakInfo,
156+
{ filename: script, line: 1 },
157157
'is back at the beginning');
158158
})
159159
.then(() => cli.command('kill'))
@@ -167,8 +167,8 @@ test('run after quit / restart', (t) => {
167167
.then(() => cli.waitForPrompt())
168168
.then(() => {
169169
t.match(
170-
cli.output,
171-
`break in ${script}:1`,
170+
cli.breakInfo,
171+
{ filename: script, line: 1 },
172172
'is back at the beginning');
173173
})
174174
.then(() => cli.quit())

deps/node-inspect/test/cli/low-level.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test('Debugger agent direct access', (t) => {
2424
.then(() => {
2525
t.match(
2626
cli.output,
27-
/scriptSource: '\(function \(/);
27+
/scriptSource:[ \n]*'(?:\(function \(|let x = 1)/);
2828
t.match(
2929
cli.output,
3030
/let x = 1;/);

deps/node-inspect/test/cli/preserve-breaks.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ test('run after quit / restart', (t) => {
3030
.then(() => cli.stepCommand('c')) // hit line 2
3131
.then(() => cli.stepCommand('c')) // hit line 3
3232
.then(() => {
33-
t.match(cli.output, `break in ${script}:3`);
33+
t.match(cli.breakInfo, { filename: script, line: 3 });
3434
})
3535
.then(() => cli.command('restart'))
3636
.then(() => cli.waitForInitialBreak())
3737
.then(() => {
38-
t.match(cli.output, `break in ${script}:1`);
38+
t.match(cli.breakInfo, { filename: script, line: 1 });
3939
})
4040
.then(() => cli.stepCommand('c'))
4141
.then(() => {
42-
t.match(cli.output, `break in ${script}:2`);
42+
t.match(cli.breakInfo, { filename: script, line: 2 });
4343
})
4444
.then(() => cli.stepCommand('c'))
4545
.then(() => {
46-
t.match(cli.output, `break in ${script}:3`);
46+
t.match(cli.breakInfo, { filename: script, line: 3 });
4747
})
4848
.then(() => cli.command('breakpoints'))
4949
.then(() => {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test('list scripts', (t) => {
2424
'lists the user script');
2525
t.notMatch(
2626
cli.output,
27-
/\d+: module\.js <native>/,
27+
/\d+: buffer\.js <native>/,
2828
'omits node-internal scripts');
2929
})
3030
.then(() => cli.command('scripts(true)'))
@@ -35,7 +35,7 @@ test('list scripts', (t) => {
3535
'lists the user script');
3636
t.match(
3737
cli.output,
38-
/\d+: module\.js <native>/,
38+
/\d+: buffer\.js <native>/,
3939
'includes node-internal scripts');
4040
})
4141
.then(() => cli.quit())

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

+26-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const BREAK_MESSAGE = new RegExp('(?:' + [
1616
'exception', 'other', 'promiseRejection',
1717
].join('|') + ') in', 'i');
1818

19+
function isPreBreak(output) {
20+
return /Break on start/.test(output) && /1 \(function \(exports/.test(output);
21+
}
22+
1923
function startCLI(args, flags = []) {
2024
const child = spawn(process.execPath, [...flags, CLI, ...args]);
2125
let isFirstStdoutChunk = true;
@@ -101,13 +105,25 @@ function startCLI(args, flags = []) {
101105
waitForInitialBreak(timeout = 2000) {
102106
return this.waitFor(/break (?:on start )?in/i, timeout)
103107
.then(() => {
104-
if (/Break on start/.test(this.output)) {
108+
if (isPreBreak(this.output)) {
105109
return this.command('next', false)
106110
.then(() => this.waitFor(/break in/, timeout));
107111
}
108112
});
109113
},
110114

115+
get breakInfo() {
116+
const output = this.output;
117+
const breakMatch =
118+
output.match(/break (?:on start )?in ([^\n]+):(\d+)\n/i);
119+
120+
if (breakMatch === null) {
121+
throw new Error(
122+
`Could not find breakpoint info in ${JSON.stringify(output)}`);
123+
}
124+
return { filename: breakMatch[1], line: +breakMatch[2] };
125+
},
126+
111127
ctrlC() {
112128
return this.command('.interrupt');
113129
},
@@ -127,19 +143,24 @@ function startCLI(args, flags = []) {
127143
.map((match) => +match[1]);
128144
},
129145

130-
command(input, flush = true) {
146+
writeLine(input, flush = true) {
131147
if (flush) {
132148
this.flushOutput();
133149
}
150+
if (process.env.VERBOSE === '1') {
151+
process.stderr.write(`< ${input}\n`);
152+
}
134153
child.stdin.write(input);
135154
child.stdin.write('\n');
155+
},
156+
157+
command(input, flush = true) {
158+
this.writeLine(input, flush);
136159
return this.waitForPrompt();
137160
},
138161

139162
stepCommand(input) {
140-
this.flushOutput();
141-
child.stdin.write(input);
142-
child.stdin.write('\n');
163+
this.writeLine(input, true);
143164
return this
144165
.waitFor(BREAK_MESSAGE)
145166
.then(() => this.waitForPrompt());

deps/node-inspect/test/cli/use-strict.test.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ test('for whiles that starts with strict directive', (t) => {
1717
return cli.waitForInitialBreak()
1818
.then(() => cli.waitForPrompt())
1919
.then(() => {
20+
const brk = cli.breakInfo;
2021
t.match(
21-
cli.output,
22-
/break in [^:]+:(?:1|2)[^\d]/,
22+
`${brk.line}`,
23+
/^(1|2)$/,
2324
'pauses either on strict directive or first "real" line');
2425
})
2526
.then(() => cli.quit())

0 commit comments

Comments
 (0)