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: fix debugger blocked main thread #5270

Closed
wants to merge 1 commit into from
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
1 change: 1 addition & 0 deletions lib/_debug_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ exports.start = function start() {
});

agent.close();
agent.clients.forEach(client => client.destroy());
};

// Not used now, but anyway
Expand Down
2 changes: 1 addition & 1 deletion src/debug-agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void Agent::Stop() {
err = uv_thread_join(&thread_);
CHECK_EQ(err, 0);

uv_close(reinterpret_cast<uv_handle_t*>(&child_signal_), nullptr);
uv_walk(&child_loop_, reinterpret_cast<uv_walk_cb>(uv_close), nullptr);
uv_run(&child_loop_, UV_RUN_NOWAIT);

err = uv_loop_close(&child_loop_);
Expand Down
24 changes: 24 additions & 0 deletions test/debugger/test-debugger-stop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';
const common = require('../common');
const debug = require('_debugger');

const fork = require('child_process').fork;

const scriptToDebug = common.fixturesDir + '/debug-connect.js';

var nodeProcess;

try {
process._debugProcess(process.pid);
} catch (ex) {
common.fail('Debugging should not fail');
}


nodeProcess = fork(scriptToDebug);
nodeProcess.send({ pid: process.pid });

nodeProcess.on('message', common.mustCall(function(m) {
process._debugEnd();
process.exit(0);
}));
24 changes: 24 additions & 0 deletions test/fixtures/debug-connect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

const assert = require('assert');
const debug = require('_debugger');
var pid;

setTimeout(function() {
if (pid) process.kill(pid, 'SIGTERM');
throw new Error('timeout');
}, 5000).unref();

function connectToDebug() {
var c = new debug.Client();
c.connect(5858);
c.on('break', function(brk) {
c.reqContinue(function() {});
});
}

process.on('message', function(m) {
pid = m.pid;
connectToDebug();
process.send({ exit: 'exit' });
});