Unitech / Unitech/pm2

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received 5000

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

I make bots on telegraf module. And together with pm2 bots time to time shutdown with this error. ReInstallation don't help this issue. I kill my brain to find solution, but not succeed. Without pm2 bots work without problems.

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received 5000
    at setTimeout (node:timers:141:3)
    at fallback (/usr/lib/node_modules/pm2/node_modules/async-listener/index.js:621:15)
    at /usr/lib/node_modules/pm2/node_modules/async-listener/index.js:651:53
    at node:internal/util:364:7
    at new Promise (<anonymous>)
    at node:internal/util:350:12
    at Polling.[Symbol.asyncIterator] (/home/marinecareer/marinecareer-bot/node_modules/telegraf/lib/core/network/polling.js:50:27)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Polling.loop (/home/marinecareer/marinecareer-bot/node_modules/telegraf/lib/core/network/polling.js:74:30) {
  code: 'ERR_INVALID_CALLBACK'
}

Supporting information

Date                 : Thu Nov 24 2022 18:50:24 GMT+0200 (Eastern European Standard Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 5.2.2
node version         : 16.18.1
node path            : /usr/bin/pm2
argv                 : /usr/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : marinecareer
uid                  : 1001
gid                  : 1001
uptime               : 1379min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 5.2.2
node version         : 16.18.1
node path            : /usr/bin/pm2
argv                 : /usr/bin/node,/usr/bin/pm2,report
argv0                : node
user                 : marinecareer
uid                  : 1001
gid                  : 1001
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel Xeon Processor (Skylake, IBRS)
cpus nb              : 1
freemem              : 1286795264
totalmem             : 2079670272
home                 : /home/marinecareer
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬──────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name             │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼──────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 1   │ ☵ index          │ default     │ 1.3.7   │ fork    │ 753745   │ 7m     │ 2    │ online    │ 0%       │ 64.4mb   │ mar… │ disabled │
│ 0   │ ☵ indexCrewing   │ default     │ 1.3.7   │ fork    │ 754070   │ 3m     │ 9    │ online    │ 0%       │ 51.9mb   │ mar… │ disabled │
└─────┴──────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
Module
┌────┬──────────────────────────────┬───────────────┬──────────┬──────────┬──────┬──────────┬──────────┬──────────┐
│ id │ module                       │ version       │ pid      │ status   │ ↺    │ cpu      │ mem      │ user     │
├────┼──────────────────────────────┼───────────────┼──────────┼──────────┼──────┼──────────┼──────────┼──────────┤
│ 2  │ pm2-logrotate                │ 2.7.0         │ 648554   │ online   │ 0    │ 0%       │ 59.6mb   │ mar… │
└────┴──────────────────────────────┴───────────────┴──────────┴──────────┴──────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/home/marinecareer/.pm2/pm2.log last 20 lines:
PM2        | 2022-11-24T18:47:08: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:08: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:08: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:08: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:08: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:08: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:08: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:08: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:09: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:09: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:09: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:09: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:09: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:09: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:09: PM2 log: pid=747045 msg=failed to kill - retrying in 100ms
PM2        | 2022-11-24T18:47:09: PM2 log: App [indexCrewing:0] exited with code [0] via signal [SIGINT]
PM2        | 2022-11-24T18:47:09: PM2 log: Process with pid 747045 still alive after 1600ms, sending it SIGKILL now...
PM2        | 2022-11-24T18:47:09: PM2 log: pid=747045 msg=process killed
PM2        | 2022-11-24T18:47:09: PM2 log: App [indexCrewing:0] starting in -fork mode-
PM2        | 2022-11-24T18:47:09: PM2 log: App [indexCrewing:0] online

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 with the reported stack locations in node_modules/pm2/node_modules/async-listener/index.js, especially fallback, and telegraf/lib/core/network/polling.js. Reproduce with Node 16.18.1 and PM2 5.2.2, then determine why setTimeout receives 5000 as its callback. Done means the failure is explained and the reported polling scenario no longer produces ERR_INVALID_CALLBACK.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.