Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I inspect the node.js event queue?

Tags:

node.js

I have what seems to be a huge memory leak in my node.js app, but when I use node-webkit-agent to examine the heap, it seems quite small. I suspect that there may be a whole ton of async operations queued up on the node.js event queue, but I'm not sure how to examine that. Is there any way to do so?

like image 880
bblack Avatar asked Aug 07 '14 23:08

bblack


People also ask

How do I monitor event loops in NodeJS?

By putting it in the queue (as opposed to just running it directly) we allow the event loop to continue looping and thus prevent the main thread from blocking. As a result, the console. log is called exactly once per event loop iteration (within each timer phase to be exact).

How do I run a node inspect?

Using the Node. To connect to it, open up Google Chrome and enter about:inspect into the URL bar and press Enter. Afterward, you will be redirected to chrome://inspect/ and be presented with a list of available devices to debug. If successful, your screen should show something similar to the image below.

What is event queue in NodeJS?

The event queue is built in. It pushes events onto the call stack, also built in, as they occur. Calls on the call stack do not get called until current call has been completed. – Blindman67.

How do NodeJS events work?

Since Node. js applications are event-driven, the events are triggered on its associated event handler. An event handler is nothing but a callback function called when an event is triggered. The main loop listens to the event triggers and then calls the corresponding event handler.


1 Answers

You can check open handles and requests by inspecting the return values of the undocumented functions process._getActiveHandles() and process._getActiveRequests() respectively. That won't get you everything that may be waiting in the event loop, but it should help.

like image 188
mscdex Avatar answered Sep 21 '22 11:09

mscdex