What keeps my process open?
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(); |
This comment has been minimized.
This comment has been minimized.
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
That seems pretty good, but it won't catch any inflight libuv requests (
process._getActiveRequests()
). But that's even harder to reason about than the handle list. I generally just hand-code a filter like yours and narrow it down until it excludes all the handles I'm expecting, and then dump the rest and start digging from there.