How can I get a list of callbacks in the Node work queue? (or, Why won't Node exit?)

后端 未结 2 1589
予麋鹿
予麋鹿 2020-11-29 18:32

It says on the Node.js about page:

Node exits the event loop when there are no more callbacks to perform.

Is there a way to find

相关标签:
2条回答
  • 2020-11-29 18:47

    You can use process._getActiveHandles() and process._getActiveRequests()

    See this discussion in node.js mailing list.

    update: there is a good package for this - https://github.com/mafintosh/why-is-node-running

    0 讨论(0)
  • 2020-11-29 18:56

    There is a npm module wtfnode to show what keep the nodejs app running when you sends SIGINT (ctrl-c) to it.

    It internal uses process._getActiveHandles() as mentioned in @andrey-sidrov's answer. The benefit of using wtfnode is that it provides easy-to-read output.

    0 讨论(0)
提交回复
热议问题