Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check events in node.js event loop

Tags:

node.js

A variation of this question was already asked here on SO (node.js Event Loop Diagnostics), however that thread is over a year old and stale.

Specifically, I want to be able to peek at the node.js Event Loop at runtime, from within the node.js process, to determine the number of events pending execution.

edit: The results of the previous question pointed to external diagnostic tools and/or internal facilities that gave insight into the length of time it took the event queue to tick.

Currently, I'm checking through the node.js doc's and libuv docs but nothing seems to be popping up. Was hoping there was an undocumented facility I could leverage..

like image 220
Kat Avatar asked Jun 09 '14 23:06

Kat


1 Answers

There are a couple of undocumented functions that return a list of open requests and open handles:

  • process._getActiveRequests()
  • process._getActiveHandles()

There is also an experimental AsyncListener API in node v0.11.12+ that allows you to add hooks for asynchronous events.

like image 199
mscdex Avatar answered Oct 11 '22 19:10

mscdex