Skip to content

Commit dee9c74

Browse files
viiryajasnell
authored andcommitted
src: fix stuck debugger process
The debug process running "node debug a.js" will be stuck when the script ends. This is because the debug handler has been unrefed. We shouldn't unref the debug handler to avoid this problem. PR-URL: #2778 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 9061aa2 commit dee9c74

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/node.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3669,7 +3669,6 @@ void Init(int* argc,
36693669
uv_async_init(uv_default_loop(),
36703670
&dispatch_debug_messages_async,
36713671
DispatchDebugMessagesAsyncCallback);
3672-
uv_unref(reinterpret_cast<uv_handle_t*>(&dispatch_debug_messages_async));
36733672

36743673
#if defined(NODE_V8_OPTIONS)
36753674
// Should come before the call to V8::SetFlagsFromCommandLine()
@@ -3976,8 +3975,11 @@ static void StartNodeInstance(void* arg) {
39763975
env->set_trace_sync_io(trace_sync_io);
39773976

39783977
// Enable debugger
3979-
if (instance_data->use_debug_agent())
3978+
if (instance_data->use_debug_agent()) {
39803979
EnableDebug(env);
3980+
} else {
3981+
uv_unref(reinterpret_cast<uv_handle_t*>(&dispatch_debug_messages_async));
3982+
}
39813983

39823984
{
39833985
SealHandleScope seal(isolate);

0 commit comments

Comments
 (0)