Skip to content

Commit

Permalink
src: fix stuck debugger process
Browse files Browse the repository at this point in the history
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: nodejs#2778
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
viirya authored and bnoordhuis committed Oct 13, 2015
1 parent 6f14b3a commit ff877e9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3652,7 +3652,6 @@ void Init(int* argc,
uv_async_init(uv_default_loop(),
&dispatch_debug_messages_async,
DispatchDebugMessagesAsyncCallback);
uv_unref(reinterpret_cast<uv_handle_t*>(&dispatch_debug_messages_async));

#if defined(NODE_V8_OPTIONS)
// Should come before the call to V8::SetFlagsFromCommandLine()
Expand Down Expand Up @@ -3959,8 +3958,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<uv_handle_t*>(&dispatch_debug_messages_async));
}

{
SealHandleScope seal(isolate);
Expand Down

0 comments on commit ff877e9

Please sign in to comment.