node app crashing after minutes when starting with mp2
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
Hey,
I have a problem with a very simple node app (recieving some data from a websocket and saving it into a MariaDB) when running it with pm2.
The app starts correcty but stops running aber 5 to 10 minutes. There are no exceptions or errors neither in the pm2 log nor in the pm2 app log... pm2 also does not restart the app automatically.
If I start the app simply by using node (npm run start) it will run for hours...
Also if I start pm2 with option --no-daemon it is runnig without problems. But then in the log I see periodically the folling error:
18:27:00 PM2 | [pidusage] We couldn't find uptime from /proc/uptime, using os.uptime() value
18:27:00 PM2 | Error caught while calling pidusage
18:27:00 PM2 | [Error: No matching pid found] {
18:27:00 PM2 | errno: -2,
18:27:00 PM2 | code: 'ENOENT',
18:27:00 PM2 | syscall: 'open',
18:27:00 PM2 | path: '/proc/449186/stat'
18:27:00 PM2 | }
Could this be the problem?
I also tried to follow the execution with pm2 monit - but there I can also see no reasons for the problem...
What else can I do to localise the error?
# Run the following commands
$ pm2 report
--- PM2 report ----------------------------------------------------------------
Date : Tue Nov 05 2024 18:01:14 GMT+0100 (Mitteleuropäische Normalzeit)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 5.4.2
node version : 18.13.0
node path : /www/htdocs/w01d9c09/bin/node/bin/pm2
argv : node,/www/htdocs/w01d9c09/bin/node/lib/node_modules/pm2/lib/Daemon.js
argv0 : node
user : ssh-w01d9c09
uid : 1048
gid : 1024
uptime : 0min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 5.4.2
node version : 18.13.0
node path : /www/htdocs/w01d9c09/bin/node/bin/pm2
argv : node,/www/htdocs/w01d9c09/bin/node/bin/pm2,report
argv0 : node
user : ssh-w01d9c09
uid : 1048
gid : 1024
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
/www/htdocs/w01d9c09/bin/node/lib/node_modules/pm2/lib/API/Extra.js:145
fmt.field('cpus', os.cpus()[0].model);
^
TypeError: Cannot read properties of undefined (reading 'model')
at /www/htdocs/w01d9c09/bin/node/lib/node_modules/pm2/lib/API/Extra.js:145:37
at /www/htdocs/w01d9c09/bin/node/lib/node_modules/pm2/node_modules/pm2-axon-rpc/lib/client.js:45:10
at Parser.<anonymous> (/www/htdocs/w01d9c09/bin/node/lib/node_modules/pm2/node_modules/pm2-axon/lib/sockets/req.js:67:8)
at Parser.emit (node:events:513:28)
at Parser._write (/www/htdocs/w01d9c09/bin/node/lib/node_modules/pm2/node_modules/amp/lib/stream.js:91:16)
at writeOrBuffer (node:internal/streams/writable:392:12)
at _write (node:internal/streams/writable:333:10)
at Writable.write (node:internal/streams/writable:337:10)
at Socket.ondata (node:internal/streams/readable:766:22)
at Socket.emit (node:events:513:28)
Node.js v18.13.0
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 report with PM2 5.4.2 and Node.js 18.13.0 on Linux, comparing daemon and --no-daemon modes. Inspect lib/API/Extra.js and the pidusage handling around /proc uptime and the missing process in /proc/449186/stat; done means identifying the cause of the stopped app or report failure and documenting a reproducible fix or next diagnostic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, linux, node.js
- Domain
- cli, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100