diff --git a/src/node.cc b/src/node.cc index d6ba87d72fd23e..892a76b63ed2e3 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3747,6 +3747,7 @@ void Init(int* argc, uv_async_init(uv_default_loop(), &dispatch_debug_messages_async, DispatchDebugMessagesAsyncCallback); + uv_unref(reinterpret_cast(&dispatch_debug_messages_async)); #if defined(NODE_V8_OPTIONS) // Should come before the call to V8::SetFlagsFromCommandLine() @@ -4054,11 +4055,8 @@ static void StartNodeInstance(void* arg) { env->set_trace_sync_io(trace_sync_io); // Enable debugger - if (instance_data->use_debug_agent()) { + if (instance_data->use_debug_agent()) EnableDebug(env); - } else { - uv_unref(reinterpret_cast(&dispatch_debug_messages_async)); - } { SealHandleScope seal(isolate);