Why-is-node-running

why-is-node-running

Node is running but you don't know why? why-is-node-running is here to help you.

This is a cheeky module that plays with process.binding of node, specifically with process.binding('contextify').ContextifyScript; the core of this library is from node's source.

GET IT: npm install --save why-is-node-running

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var log = require('why-is-node-running'); // should be your first require 
var net = require('net');

function createServer () {
  var server = net.createServer();
  setInterval(function () {}, 1000);
  server.listen(0);
}

createServer();
createServer();

setTimeout(function () {
  log() // logs out active handles that are keeping node running 
}, 100);

When executed in /tmp you see an output like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
There are 4 known handle(s) keeping the process running and 0 unknown
Known handles:

# Timer
/private/tmp/l:6  - setInterval(function () {}, 1000);
/private/tmp/l:10 - createServer();

# TCP
/private/tmp/l:7  - server.listen(0);
/private/tmp/l:10 - createServer();

# TCP
/private/tmp/l:7  - server.listen(0);
/private/tmp/l:11 - createServer();

# Timer
/private/tmp/l:13 - setTimeout(function () {

GIF FTW!

why-is-node-running

Suggest a module

Comments