Unitech / Unitech/pm2

# `pm2 delete` overwrites original process status (`errored` → `stopped`)

Open
#6,059 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

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

  1. Create a script that immediately crashes:
// crash.js
throw new Error("fail");
  1. Start it with PM2:
pm2 start crash.js --name test-crash --max-restarts 1
  1. Wait for the process to enter the "errored" state (max_restarts reached).

  2. Delete the process programmatically:

pm2.delete("test-crash", (err, proc) => {
  console.log("Status in delete callback:", proc.pm2_env.status);
});
  1. 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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.