Last active
August 29, 2015 14:02
-
-
Save Raynos/df7a19a30faa917671d3 to your computer and use it in GitHub Desktop.
What keeps my process open?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var setInterval = require('timers').setInterval; | |
setInterval(function () { | |
var handles = process._getActiveHandles(); | |
console.log('no of handles', handles.length); | |
handles.forEach(function (obj) { | |
if ('ontimeout' in obj) { | |
console.log('timer handle', obj); | |
} else if ('readable' in obj && 'writable' in obj) { | |
// to debug stream handles print the _events functions | |
// to string and figure out what kind of stream they are | |
// then stare really hard at the source code | |
// console.log(obj._events.end.toString()); | |
console.log('stream handle', obj); | |
} else { | |
console.log('unknown handle', obj); | |
} | |
}) | |
}, 5000).unref(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
obj.owner
is the owning "public" object, e.g. the encapsulating net.Socket for a TCP handle.Doesn't work for regular timers because they sit in a queue backed by a single timer handle but it does work for timers that have been unref()'d; those get moved out of the queue and assigned individual timer handles.