Can I get the contents of the event loop?

428 views
Skip to first unread message

beatgammit

unread,
Dec 20, 2011, 3:35:35 PM12/20/11
to nodejs
I'm trying to debug a callback not being called, but a lot of things
are going on, and it would be impractical to walk through it all. I'm
running an automated test that does thousands of http requests. It
works, but the application doesn't exit.

My question is, is there a way to get the contents of the inner event
loop? I'm currently on node 4.12. I would ultimately like to
forcefully crash node and get all of the callbacks in the event loop
with their contexts (values of variables in a closure, etc).

I'm currently using node-inspector in debugging, but it also hangs
like this without running the code in debug mode.

Thanks!

Ben Noordhuis

unread,
Dec 20, 2011, 4:27:29 PM12/20/11
to nod...@googlegroups.com
On Tue, Dec 20, 2011 at 21:35, beatgammit <beatg...@gmail.com> wrote:
> I'm trying to debug a callback not being called, but a lot of things
> are going on, and it would be impractical to walk through it all.  I'm
> running an automated test that does thousands of http requests. It
> works, but the application doesn't exit.
>
> My question is, is there a way to get the contents of the inner event
> loop? I'm currently on node 4.12.  I would ultimately like to

https://github.com/bnoordhuis/node/compare/v0.6...print-handles

It's preliminary work I did on event loop / reference count debugging
(but v0.6 only)...

> forcefully crash node and get all of the callbacks in the event loop
> with their contexts (values of variables in a closure, etc).

...but it doesn't do that.

beatgammit

unread,
Dec 20, 2011, 4:46:30 PM12/20/11
to nodejs
Cool! I take that to mean that there is no way to do this in v0.4.

I'm not too familiar with the JavaScript->C++ interface. How would I
call this from JavaScript? I have a specific part in the code where I
would need to print everything.

On Dec 20, 2:27 pm, Ben Noordhuis <i...@bnoordhuis.nl> wrote:

Ben Noordhuis

unread,
Dec 20, 2011, 5:23:21 PM12/20/11
to nod...@googlegroups.com
On Tue, Dec 20, 2011 at 22:46, beatgammit <beatg...@gmail.com> wrote:
> Cool! I take that to mean that there is no way to do this in v0.4.
>
> I'm not too familiar with the JavaScript->C++ interface. How would I
> call this from JavaScript? I have a specific part in the code where I
> would need to print everything.

There is no JS API, just send a SIGUSR2 to the `node` process and it
will print a list of active handles.

I suppose it's useful mostly to core or add-on developers but it might
give you a hint as to what is keeping your event loop alive ("hey,
what's that stray timer doing there?").

Reply all
Reply to author
Forward
0 new messages