-
-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Labels
Description
With v2.0.3, invoking the exported log disables the hook. I needed a more complete picture of what was going on during closing of an application because the answer to "why is node running" kept changing. Hence, I tried to sample open handlers as shown below.
for (let i = 0; i < 10; i++) {
setTimeout(log, (i + 1) * 500);
}However, this was obviously not possible. It worked with the following patch, in case anyone also needs this, and I am lightly suggesting it as an addition.
--- index.js
+++ index.js
@@ -23,9 +23,8 @@
function whyIsNodeRunning (logger) {
if (!logger) logger = console
- hook.disable()
logger.error('There are %d handle(s) keeping the process running', active.size)
- for (const o of active.values()) printStacks(o)
+ for (const o of [...active.values()]) printStacks(o)
function printStacks (o) {
var stacks = o.stacks.slice(1).filter(function (s) {