Skip to content

Commit dfdd911

Browse files
committed
lib: deprecate node --debug at runtime
Fixes: #9789 PR-URL: #10970 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Ali Ijaz Sheikh <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent df14956 commit dfdd911

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

doc/api/deprecations.md

+9
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,15 @@ Type: Documentation-only
511511
The `fs.SyncWriteStream` class was never intended to be a publicly accessible
512512
API.
513513

514+
<a id="DEP0062"></a>
515+
### DEP0062: node --debug
516+
517+
Type: Runtime
518+
519+
`--debug` activates the legacy V8 debugger interface, which has been removed as
520+
of V8 5.8. It is replaced by Inspector which is activated with `--inspect`
521+
instead.
522+
514523
[alloc]: buffer.html#buffer_class_method_buffer_alloc_size_fill_encoding
515524
[alloc_unsafe_size]: buffer.html#buffer_class_method_buffer_allocunsafe_size
516525
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size

lib/_debug_agent.js

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

3+
process.emitWarning(
4+
'node --debug is deprecated. Please use node --inspect instead.',
5+
'DeprecationWarning',
6+
'DEP0062');
7+
38
const assert = require('assert');
49
const net = require('net');
510
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+\) \[DEP0062\] 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)