-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Description
Summary
When calling pm2.delete() on a process that is in an "errored" state, the process object received in the delete callback always reports:
pm2_env.status = "stopped"
The original status is overwritten during the delete operation, so the caller cannot determine whether the process previously failed or exited normally.
Steps to Reproduce
- Create a script that immediately crashes:
// crash.js
throw new Error("fail");- Start it with PM2:
pm2 start crash.js --name test-crash --max-restarts 1-
Wait for the process to enter the
"errored"state (max_restartsreached). -
Delete the process programmatically:
pm2.delete("test-crash", (err, proc) => {
console.log("Status in delete callback:", proc.pm2_env.status);
});- The callback output always shows:
"stopped"
regardless of the process’s actual final state before deletion.
Environment
PM2 version: 5.3.1
Node version: 18.x
OS: Linux
Metadata
Metadata
Assignees
Labels
No labels