Skip to content

Commit ff877e9

Browse files
viiryabnoordhuis
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 6f14b3a commit ff877e9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/node.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -3652,7 +3652,6 @@ void Init(int* argc,
36523652
uv_async_init(uv_default_loop(),
36533653
&dispatch_debug_messages_async,
36543654
DispatchDebugMessagesAsyncCallback);
3655-
uv_unref(reinterpret_cast<uv_handle_t*>(&dispatch_debug_messages_async));
36563655

36573656
#if defined(NODE_V8_OPTIONS)
36583657
// Should come before the call to V8::SetFlagsFromCommandLine()
@@ -3959,8 +3958,11 @@ static void StartNodeInstance(void* arg) {
39593958
env->set_trace_sync_io(trace_sync_io);
39603959

39613960
// Enable debugger
3962-
if (instance_data->use_debug_agent())
3961+
if (instance_data->use_debug_agent()) {
39633962
EnableDebug(env);
3963+
} else {
3964+
uv_unref(reinterpret_cast<uv_handle_t*>(&dispatch_debug_messages_async));
3965+
}
39643966

39653967
{
39663968
SealHandleScope seal(isolate);

0 commit comments

Comments
 (0)