# `pm2 delete` overwrites original process status (`errored` → `stopped`)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
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
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 at the pm2.delete() callback path and reproduce the issue with crash.js using the shown PM2 and Node versions. Trace where the process status changes during deletion; done means the callback reports the status from before deletion, including "errored", with regression coverage demonstrating it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100