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

debugger: check -e flag in debug break setup #8876

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ Module.prototype._compile = function(content, filename) {
displayErrors: true
});

if (process._debugWaitConnect) {
if (process._debugWaitConnect && process._eval == null) {
if (!resolvedArgv) {
// we enter the repl if we're not given a filename argument.
if (process.argv[1]) {
Expand Down
71 changes: 43 additions & 28 deletions test/parallel/test-debug-brk.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,48 @@
const common = require('../common');
const spawn = require('child_process').spawn;

var procStderr = '';
var agentStdout = '';
var needToSpawnAgent = true;
var needToExit = true;

const procArgs = [`--debug-brk=${common.PORT}`, '-e', '0'];
const proc = spawn(process.execPath, procArgs);
proc.stderr.setEncoding('utf8');

const exitAll = common.mustCall((processes) => {
processes.forEach((myProcess) => { myProcess.kill(); });
});

proc.stderr.on('data', (chunk) => {
procStderr += chunk;
if (/Debugger listening on/.test(procStderr) && needToSpawnAgent) {
needToSpawnAgent = false;
const agentArgs = ['debug', `localhost:${common.PORT}`];
const agent = spawn(process.execPath, agentArgs);
agent.stdout.setEncoding('utf8');

agent.stdout.on('data', (chunk) => {
agentStdout += chunk;
if (/connecting to .+ ok/.test(agentStdout) && needToExit) {
needToExit = false;
exitAll([proc, agent]);
let run = () => {};
function test(extraArgs) {
const next = run;
run = () => {
var procStderr = '';
var agentStdout = '';
var needToSpawnAgent = true;
var needToExit = true;

const procArgs = [`--debug-brk=${common.PORT}`].concat(extraArgs);
const proc = spawn(process.execPath, procArgs);
proc.stderr.setEncoding('utf8');

const exitAll = common.mustCall((processes) => {
processes.forEach((myProcess) => { myProcess.kill(); });
});

proc.stderr.on('data', (chunk) => {
procStderr += chunk;
if (/Debugger listening on/.test(procStderr) && needToSpawnAgent) {
needToSpawnAgent = false;
const agentArgs = ['debug', `localhost:${common.PORT}`];
const agent = spawn(process.execPath, agentArgs);
agent.stdout.setEncoding('utf8');

agent.stdout.on('data', (chunk) => {
agentStdout += chunk;
if (/connecting to .+ ok/.test(agentStdout) && needToExit) {
needToExit = false;
exitAll([proc, agent]);
}
});
}
});
}
});

proc.on('exit', () => {
next();
});
};
}

test(['-e', '0']);
test(['-e', '0', 'foo']);

run();