I started using const { spawn } = require('child_process') in my nodejs app and PM2 started throwing the following errors:
at Timeout._onTimeout (/usr/local/lib/node_modules/pm2/node_modules/@pm2/io/build/main/metrics/eventLoopMetrics.js:39:43)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)
TypeError: process._getActiveRequests is not a function
at Timeout._onTimeout (/usr/local/lib/node_modules/pm2/node_modules/@pm2/io/build/main/metrics/eventLoopMetrics.js:39:43)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)
/usr/local/lib/node_modules/pm2/node_modules/@pm2/io/build/main/features/notify.js:122
if (process.listeners('uncaughtException').length === 1) {
^
TypeError: process.listeners is not a function
at NotifyFeature.onUncaughtException (/usr/local/lib/node_modules/pm2/node_modules/@pm2/io/build/main/features/notify.js:122:21)
at process.emit (node:events:390:28)
at process._fatalException (node:internal/process/execution:170:25)
The weird thing is that when I stop the process in PM2 and run it directly with node it works perfectly. But I can't find a way to fix it from PM2.