From dee9c74c180de04aa48849f4ca4df1f43b7a7481 Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Thu, 10 Sep 2015 00:41:15 +0800 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/2778 Reviewed-By: Ben Noordhuis --- src/node.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node.cc b/src/node.cc index b80996e233a760..8766e3a1430f90 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3669,7 +3669,6 @@ 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() @@ -3976,8 +3975,11 @@ 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);