Skip to content

debugger: fix stuck debugger when debuggee exits

Checklist
  • tests and code linting passes
  • a test and/or benchmark is included
  • the commit message follows commit guidelines
Affected core subsystem(s)

debugger

Description of change

Referencing PR #27778

The debuggee node process will never exit because the execution is blocked inside node::debugger::Agent::Stop, joining the agent thread. The debug agent thread is blocked inside uv_run.

To fix this, the debug agent has to close all client connections in _debug_agent.js (process._debugAPI.onclose).

Additionally all remaining opened handles have to be closed before calling uv_loop_close. Otherwise uv_loop_close will fail with UV_EBUSY.

Assume the following script (debug.js):

console.log('debug');

Calling node debug debug.js produces the following output:

< Debugger listening on port 5858
connecting to 127.0.0.1:5858 ... ok
break in debug.js:1
> 1 console.log('debug');
  2 
  3 });
debug> c
< debug
program terminated
debug> 

Both

node --debug -e 0

and

node --debug-brk -e 0

exit immediately.

Merge request reports

Loading