Unitech / Unitech/pm2

TypeError: Cannot set properties of undefined (setting 'start_timer')

Open
#5,210 4 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

What's going wrong?

Can not restart pm2 programmatically

How could we reproduce this issue?

I am running a ts application, with "skipLibCheck": true and "allowJs": true

using

import { connect, disconnect, flush, restart } from "pm2"

seems to cause the problem. Using the standard js require works normal

Supporting information

$ pm2 report
--- PM2 report ----------------------------------------------------------------
Date                 : Mon Oct 25 2021 21:18:33 GMT+0200 (Central European Summer Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 5.1.0
node version         : 16.9.1
node path            : /usr/local/bin/pm2
argv                 : /usr/local/bin/node,/usr/local/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : sambauser
uid                  : 1001
gid                  : 1001
uptime               : 10min
===============================================================================
node path            : /usr/local/bin/pm2
argv                 : /usr/local/bin/node,/usr/local/bin/pm2,report
argv0                : node
user                 : sambauser
uid                  : 1001
gid                  : 1001
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) CPU           X3480  @ 3.07GHz
cpus nb              : 8
freemem              : 2003755008
totalmem             : 8327303168
home                 : /home/sambauser
===============================================================================
--- PM2 list -----------------------------------------------
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name               │ mode     │ ↺    │ status    │ cpu      │ memory   │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 1  │ ETIT-Master        │ fork     │ 3    │ online    │ 0%       │ 217.6mb  │
│ 3  │ PersonalReminder   │ fork     │ 0    │ online    │ 0%       │ 73.4mb   │
│ 2  │ ReminderBot        │ fork     │ 0    │ online    │ 0%       │ 72.4mb   │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
host metrics | cpu: 2.6% 36.0º | mem free: 87.2% | enp3s0: ⇓ 0.002mb/s ⇑ 0.009mb/s |
===============================================================================
--- Daemon logs --------------------------------------------
/home/sambauser/.pm2/pm2.log last 20 lines:
PM2        | 2021-10-25T21:07:46: PM2 log: App [ETIT-Master:1] online
PM2        | 2021-10-25T21:08:16: PM2 log: App [ReminderBot:2] starting in -fork mode-
PM2        | 2021-10-25T21:08:16: PM2 log: App [ReminderBot:2] online
PM2        | 2021-10-25T21:08:29: PM2 log: App [PersonalReminder:3] starting in -fork mode-
PM2        | 2021-10-25T21:08:29: PM2 log: App [PersonalReminder:3] online
PM2        | 2021-10-25T21:15:04: PM2 log: Stopping app:ETIT-Master id:1
PM2        | 2021-10-25T21:15:04: PM2 log: App [ETIT-Master:1] exited with code [0] via signal [SIGINT]
PM2        | 2021-10-25T21:15:04: PM2 log: pid=2717031 msg=process killed
PM2        | 2021-10-25T21:15:04: PM2 log: App [ETIT-Master:1] starting in -fork mode-
PM2        | 2021-10-25T21:15:04: PM2 log: App [ETIT-Master:1] online
PM2        | 2021-10-25T21:15:44: PM2 log: Stopping app:ETIT-Master id:1
PM2        | 2021-10-25T21:15:44: PM2 log: App [ETIT-Master:1] exited with code [0] via signal [SIGINT]
PM2        | 2021-10-25T21:15:44: PM2 log: pid=2727695 msg=process killed
PM2        | 2021-10-25T21:15:44: PM2 log: App [ETIT-Master:1] starting in -fork mode-
PM2        | 2021-10-25T21:15:44: PM2 log: App [ETIT-Master:1] online
PM2        | 2021-10-25T21:16:14: PM2 log: Stopping app:ETIT-Master id:1
PM2        | 2021-10-25T21:16:14: PM2 log: App [ETIT-Master:1] exited with code [0] via signal [SIGINT]
PM2        | 2021-10-25T21:16:14: PM2 log: pid=2728632 msg=process killed
PM2        | 2021-10-25T21:16:14: PM2 log: App [ETIT-Master:1] starting in -fork mode-
PM2        | 2021-10-25T21:16:14: PM2 log: App [ETIT-Master:1] online

And the error I am getting is the following:

TypeError: Cannot set properties of undefined (setting 'start_timer')
 at connect (/PATH/TO/FOLDER/ETIT-Master/node_modules/pm2/lib/API.js:166:22)

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

Inspect node_modules/pm2/lib/API.js at line 166 and compare the named TypeScript import with the working require form. Reproduce the issue with PM2 5.1.0 and Node 16.9.1, then confirm that connect, disconnect, flush, and restart can be imported and restart completes without the TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, typescript
Domain
devops, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.