my nodejs process which was running at Linux, now it is hang and the CPU is 100%. Is there anyway I can do to debug it and find the reason? Do I need to collect dump and how? Thanks.
Asked
Active
Viewed 1.6k times
17
-
Maybe this will be useful https://www.joyent.com/blog/mdb-and-node-js – raidendev Jul 24 '14 at 07:21
-
1Have a look at http://stackoverflow.com/questions/1911015/how-to-debug-node-js-applications/16512303#16512303 – Matt Harrison Jul 24 '14 at 07:21
-
Plus you can always run `strace` – Nitzan Shaked Jul 24 '14 at 07:30
-
@raidendev Can MDB be used in CentOS? – kevin_song Jul 24 '14 at 08:35
-
Should be, try `yum install mdbtools` – raidendev Jul 24 '14 at 08:37
-
@raidendev that's a different package, it contains tools for working with MS Access databases – maccam94 Apr 23 '19 at 05:48
2 Answers
13
There's an npm module called why-is-node-running that can give you info like:
There are 4 known handle(s) keeping the process running and 0 unknown
Known handles:
# Timer
/Users/maf/dev/node_modules/why-is-node-running/example.js:6 - setInterval(function () {}, 1000)
/Users/maf/dev/node_modules/why-is-node-running/example.js:10 - createServer()
# TCP
/Users/maf/dev/node_modules/why-is-node-running/example.js:7 - server.listen(0)
/Users/maf/dev/node_modules/why-is-node-running/example.js:10 - createServer()
# TCP
/Users/maf/dev/node_modules/why-is-node-running/example.js:7 - server.listen(0)
/Users/maf/dev/node_modules/why-is-node-running/example.js:11 - createServer()
# Timer
/Users/maf/dev/node_modules/why-is-node-running/example.js:13 - setTimeout(function () {
B T
- 52,424
- 34
- 173
- 199
-
Excellent! Now I know what's in the way. This is exactly what I was looking for. – Alexis Wilke Nov 28 '18 at 18:03
-
This tool helps with processes which have completed their work but not exited the vm. It does not help with infinite loops, which is what this question is about. – Rich May 23 '22 at 14:49
1
For me the why-is-node-running package was not very useful since I had an infinite while loop.
I wish there was a tool that will detect infinite loop all around the project.
What solve for me the issue was to manually reverse some versions of my project and to manually re-add the code I deleted, until I found out what cause my application to hangs, as I said, a infinite while loop.
Or Assayag
- 4,346
- 10
- 43
- 76