Why won't Node close? What's in the work queue?

3,711 views
Skip to first unread message

Kurt Blackwell

unread,
Jun 29, 2013, 8:58:16 AM6/29/13
to nod...@googlegroups.com
Hi all,

I'm just wondering if there's a way of debugging Node's internal work queue, like finding out how many setTimeout()s are waiting, or what network connections are preventing Node from closing.  Ideally I would see the callback associated with them.

Most npm packages seem to have poor error handling, and often fail to close all their resources properly.  Surely there must be a way to debug these?

Thanks for your help.

Ben Noordhuis

unread,
Jun 29, 2013, 7:42:57 PM6/29/13
to nod...@googlegroups.com
On Sat, Jun 29, 2013 at 2:58 PM, Kurt Blackwell
<kurt.bl...@gmail.com> wrote:
> Hi all,
>
> I'm just wondering if there's a way of debugging Node's internal work queue,
> like finding out how many setTimeout()s are waiting, or what network
> connections are preventing Node from closing. Ideally I would see the
> callback associated with them.

There's process._getActiveHandles() and process._getActiveRequests().

Timers are problematic. They don't usually have a one-to-one mapping
with a libuv handle so process._getActiveHandles() won't report them.

Kurt Blackwell

unread,
Jul 1, 2013, 10:29:12 AM7/1/13
to nod...@googlegroups.com
Thanks Ben, that's what I needed.

Actually, for my current debugging test, I am seeing timer callbacks listed in _getActiveRequests().  It's necessary to navigate a linked list to get at them, but it's still super helpful.
Reply all
Reply to author
Forward
0 new messages