0

Is there a way to know the number of pending "threads"/tasks to be executed in the main loop of a nodejs program ?

We know that a very basic setInterval/setTimeout/process.nextTick will create a tick in the stack that prevent the program to die, but is there a way to introspect this ?

   //in some module
   //some js code

   return 22;
   //is the program still active after this line or not ?

I guess i'm searching for a "process.hasPendingTasks()" or something like that...

131
  • 3,071
  • 31
  • 32

1 Answers1

0

There are the undocumented functions:

process._getActiveHandles();
process._getActiveRequests();

Which should give you some information as to what is left to execute.

Dave Irvine
  • 384
  • 4
  • 14