Skip to content

Commit 614742b

Browse files
joshgavitaloacasas
authored andcommitted
lib: deprecate node --debug at runtime
PR-URL: #11275 Backport-of: #10970 Reviewed-By: James M Snell <[email protected]>
1 parent b1b6b8b commit 614742b

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

lib/_debug_agent.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
process.emitWarning(
4+
'node --debug is deprecated. Please use node --inspect instead.',
5+
'DeprecationWarning');
6+
37
const assert = require('assert');
48
const net = require('net');
59
const util = require('util');

test/parallel/test-debug-port-from-cmdline.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22
const common = require('../common');
33
const assert = require('assert');
44
const spawn = require('child_process').spawn;
5+
const os = require('os');
56

67
const debugPort = common.PORT;
78
const args = ['--interactive', '--debug-port=' + debugPort];
89
const childOptions = { stdio: ['pipe', 'pipe', 'pipe', 'ipc'] };
910
const child = spawn(process.execPath, args, childOptions);
1011

12+
const reDeprecationWarning = new RegExp(
13+
/^\(node:\d+\) DeprecationWarning: /.source +
14+
/node --debug is deprecated. /.source +
15+
/Please use node --inspect instead.$/.source
16+
);
17+
1118
child.stdin.write("process.send({ msg: 'childready' });\n");
1219

1320
child.stderr.on('data', function(data) {
@@ -37,12 +44,20 @@ function processStderrLine(line) {
3744
}
3845

3946
function assertOutputLines() {
40-
const expectedLines = [
41-
'Starting debugger agent.',
42-
'Debugger listening on 127.0.0.1:' + debugPort,
47+
// need a var so can swap the first two lines in following
48+
// eslint-disable-next-line no-var
49+
var expectedLines = [
50+
/^Starting debugger agent.$/,
51+
reDeprecationWarning,
52+
new RegExp(`^Debugger listening on 127.0.0.1:${debugPort}$`)
4353
];
4454

55+
if (os.platform() === 'win32') {
56+
expectedLines[1] = expectedLines[0];
57+
expectedLines[0] = reDeprecationWarning;
58+
}
59+
4560
assert.strictEqual(outputLines.length, expectedLines.length);
4661
for (let i = 0; i < expectedLines.length; i++)
47-
assert(expectedLines[i].includes(outputLines[i]));
62+
assert(expectedLines[i].test(outputLines[i]));
4863
}

test/parallel/test-debug-signal-cluster.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const path = require('path');
88

99
const port = common.PORT;
1010
const serverPath = path.join(common.fixturesDir, 'clustered-server', 'app.js');
11-
const args = [`--debug-port=${port}`, serverPath];
11+
// cannot use 'Flags: --no-deprecation' since it doesn't effect child
12+
const args = [`--debug-port=${port}`, '--no-deprecation', serverPath];
1213
const options = { stdio: ['inherit', 'inherit', 'pipe', 'ipc'] };
1314
const child = spawn(process.execPath, args, options);
1415

0 commit comments

Comments
 (0)