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

后端 未结 2 1607
予麋鹿
予麋鹿 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: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.

提交回复
热议问题