Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging multiple times over the course of a programs lifetime #42

Open
badeball opened this issue Oct 26, 2018 · 2 comments
Open

Logging multiple times over the course of a programs lifetime #42

badeball opened this issue Oct 26, 2018 · 2 comments

Comments

@badeball
Copy link

badeball commented Oct 26, 2018

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) {
@mafintosh
Copy link
Owner

That's okay with me. Wanna PR your patch? :)

@badeball
Copy link
Author

Done with #43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants