Unitech / Unitech/pm2

connect EAGAIN /home/user/.pm2/rpc.sock

Open
#5,969 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

Under high load (lots of apps running, like 250, each eating 50 - 60 MB of memory on a 128 GB Ubuntu 22.04 box, with 128 GB VM), this happens almost daily when issuing pm2 list or any other pm2 command:

connect EAGAIN /home/user/.pm2/rpc.sock
node:events:497
      throw er; // Unhandled 'error' event
      ^

Error: connect EAGAIN /home/user/.pm2/rpc.sock
    at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1607:16)
Emitted 'error' event on ReqSocket instance at:
    at Socket.<anonymous> (/usr/local/lib/node_modules/pm2/node_modules/pm2-axon/lib/sockets/sock.js:201:49)
    at Socket.emit (node:events:519:28)
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -11,
  code: 'EAGAIN',
  syscall: 'connect',
  address: '/home/user/.pm2/rpc.sock'
}

Node.js v20.17.0

After that the pm2 list "disappears", somehow the processes still run in an unattached "zombie" state and do their thing, but the connection to the pm2 command line app is broken until I issue pm2 update which sometimes re-links them, and sometimes not, so all I can do to get control of my apps again is kill -9 them, kill PM2 God Process (of which there are strangely multiple, is that expected?), kill everything like Kylo Ren. Sometimes rm -rf ~/.pm2 also helps but the zombie processes often are still there and keep resurrecting.

I mean perhaps the system is overwhelmed by launching so many apps, but all exceptions should be caught and handled gracefully, right?

Otherwise great software, I don't know what I'd do without it. That's what makes this so difficult!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with many applications while running pm2 list, then inspect the RPC socket path and the pm2-axon socket code at sock.js:201 from the stack trace. Determine how the EAGAIN connection error affects the CLI and PM2 God processes; done means the command handles the failure without becoming unusable or leaving processes unmanaged.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
backend, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.