Skip to content

Commit 66029bf

Browse files
committed
src: fixing debug process stuck
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.
1 parent 31c971d commit 66029bf

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)