Unitech / Unitech/pm2

[JS API] `PM2.start` returns empty array, possibly related to caching

Open
#5,581 1 comment 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

What's going wrong?

When running PM2 start from the JavaScript API, an empty array is returned with no error. The process does not start, nor is there a record of it using pm2 list. Running PM2 as a different user resolves this. Deleting the PM2 cache using rm -rf ~/.pm2 does not resolve this. Running the PM2 command directly resolves this (instead of via PM2 JS API). Running via CLI resolves this. Killing all processes with pm2 in the name does not resolve this.

/*
    {
      "interpreter": "node",
      "interpreter_args": " \"/home/user/cli.js\" server --trace-warnings --is-daemon=true --daemon-name=payments  ",
      "name": "payments",
      "script": "\"/home/user/cli.js\" server --trace-warnings --is-daemon=true --daemon-name=payments  ",
      "cwd": "/home/user/payments",
      "time": true,
      "output": "/home/user/.logs/payments.log",
      "error": "/home/user/.logs/payments.err.log",
      "exec_mode": "fork",
      "exp_backoff_restart_delay": 100,
      "max_memory_restart": "150M",
      "autorestart": false,
      "restart_delay": 10000,
      "kill_timeout": 10000,
      "shutdown_with_message": false,
      "env": {},
      "instances": 1
    }
*/
pm2.start(options, handler); // returns empty array and no error in handler

However, using the CLI, this works:

pm2 start --name=payments "node \"/home/user/cli.js\" server --trace-warnings --is-daemon=true --daemon-name=payments"

How could we reproduce this issue?

Hard to repro. I imagine this is a caching issue.

Supporting information

v5.1.2
Node v19.5.0

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

No source file or test is named. Start by reproducing PM2.start(options, handler) on PM2 v5.1.2 with Node v19.5.0, then compare it with the equivalent CLI command and inspect the API path involved in process registration or caching. Done means the process starts through the JavaScript API and returns the expected result or an actionable error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.