Closed shanehughes3 closed 5 years ago
It appears it's an upstream issue with async-listener
: othiym23/async-listener#136. The maintainer there, however, recommends using native async hooks.
cc @vmarchaud
Hey,
It should be fixed with a pm2 re-installation:
npm install pm2 -g
pm2 update
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' }
2022 close to end. Problem still exist. Node 18, Ubuntu 22, Telegraf 4.8 for telegram bots. Every day it`s shut down my bots.
I have the same issue. It only occours using the trace = true option though. Workaround for now is trace = false. Maybe this can hint to a fix?
What's going wrong?
PM2 is preventing node's
util.promisify
function from properly handlingsetTimeout
. This is a code pattern recommended by the node documentation that allows setting timeouts that flow within promise chains or async functions. Running this code with node outside of pm2 does not result in an error.I am not positive when this issue began, but I know that it did not exist a month ago.
The error received is:
How could we reproduce this issue?
Create a
pm2test.js
with the following:First, run this directly with node:
Now start with pm2:
pm2 start pm2test.js
and observe the log output, which produces the above error.Supporting information