Skip to content

# pm2 delete overwrites original process status (erroredstopped) #6059

@galio1238

Description

@galio1238

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions