Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(backport 7.x) lib: deprecate node --debug at runtime #11275

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/_debug_agent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

process.emitWarning(
'node --debug is deprecated. Please use node --inspect instead.',
'DeprecationWarning');

const assert = require('assert');
const net = require('net');
const util = require('util');
Expand Down
23 changes: 19 additions & 4 deletions test/parallel/test-debug-port-from-cmdline.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
const common = require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;
const os = require('os');

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

const reDeprecationWarning = new RegExp(
/^\(node:\d+\) DeprecationWarning: /.source +
/node --debug is deprecated. /.source +
/Please use node --inspect instead.$/.source
);

child.stdin.write("process.send({ msg: 'childready' });\n");

child.stderr.on('data', function(data) {
Expand Down Expand Up @@ -37,12 +44,20 @@ function processStderrLine(line) {
}

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

if (os.platform() === 'win32') {
expectedLines[1] = expectedLines[0];
expectedLines[0] = reDeprecationWarning;
}

assert.strictEqual(outputLines.length, expectedLines.length);
for (let i = 0; i < expectedLines.length; i++)
assert(expectedLines[i].includes(outputLines[i]));
assert(expectedLines[i].test(outputLines[i]));
}
3 changes: 2 additions & 1 deletion test/parallel/test-debug-signal-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const path = require('path');

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

Expand Down