Cant activate inspector in cluster mode
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
Hi, thanks for the package, have been using it for a long time without issues.
Recently, a production app showed signs of a memory leak. The app is running in cluster mode, pm2 v5.1.2, node v14.18.2, ubuntu 18.04. In order to debug it I decided to take heap snapshots using node-oom-heapdump, but taking a heap snapshot requires an active inspector.
So I spent a whole day trying to activate the inspector in pm2 cluster mode. I tried every possible way of passing the --inspect node argument in pm2, but couldn't make it work. Then I tried to activate the inspector programmatically using
const inspector = require('inspector');
inspector.open(9229)
but I kept getting this error
[ERR_INSPECTOR_ALREADY_ACTIVATED]: Inspector is already activated. Close it with inspector.close() before activating it again.
Right before calling inspector.open() I logged inspector.url() to see on which port it was running, but it returned undefined.
I also tried closing it with inspector.close() before calling open(), but I kept getting the same error.
Is there any way to activate the inspector in cluster mode ? I know it works in fork mode, but I can't use fork mode in production, the app currently uses 12 workers and it's barely enough to keep up with the load.
An alternative solution to my original issue would be taking heap snapshots without the inspector, but I doubt that it's possible.
Thanks in advance!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported behavior in PM2 cluster mode with Node.js 14.18.2, focusing on inspector.open(), inspector.url(), and inspector.close(). Compare inspector activation in cluster and fork modes; done means establishing whether heap snapshots can be supported and documenting or fixing the activation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100