0

I have code that runs on NodeJS which involves intervals, sockets, and other async things.

Sometimes when it should close, it hangs forever, presumably since somewhere under some circumstances, I forget to clear an interval, close a socket, or something else.

Is there a way to get the currently active timers, and other such runtime information? Or inspect in any kind of way what blocks the exit?

6
  • Yeah, a debugger. Commented Mar 1, 2018 at 4:19
  • I tried searching for information under the global process object, but couldn't find anything there. Any hints? :) Commented Mar 1, 2018 at 4:24
  • Is there a reason you don't just use process.exit() when you want your program to exit? Commented Mar 1, 2018 at 4:28
  • process.exit() seems very hacky to me, no other reason really. Commented Mar 1, 2018 at 4:32
  • It's not hacky at all. It's a core concept of nearly any program in any OS. The program tells the OS when it's done and wants to exit. All node.js is doing with all its timer and socket counters is just trying to decide when to call the same function to cause the program to exit. If it's clear to you when you're done with everything and you want your program to exit, just call process.exit(). Commented Mar 1, 2018 at 6:33

1 Answer 1

1

Found this package https://www.npmjs.com/package/wtfnode from a related question to this one (https://stackoverflow.com/a/38471228/2503048). Oddly enough I couldn't find this information when googling. It should probably answer my question. Mostly the part about process._getActiveHandles().

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.