pm2-io-apm icon indicating copy to clipboard operation
pm2-io-apm copied to clipboard

Unhandled Error in IPCTransport.autoExitHook when running under Deno 2

Open mikuso opened this issue 11 months ago • 0 comments

The autoExitHook method of the IPCTransport class calls an undocumented method of the node.js process class, namely _getActiveHandles.

This method does not exist in the process class of Deno 2, and so causes a crash when running under that environment.

I note that this isn't the only place in the @pm2/io code where this undocumented method is used; However, in the other instance, there is a safety check to ensure that this undocumented method exists before calling it.

See the init method of EventLoopHandlesRequestsMetric, where the following safety check is made before calling the undocumented method:

if (typeof (process as any)._getActiveHandles === 'function' && ...

As a quick-fix (without admittedly understanding the significance of autoExitHook), I would suggest adding a similar safety check to the autoExitHook method so as to not cause crashes in Deno 2. In the worst case, this change would result in a less severe bug when running under Deno 2.

mikuso avatar Nov 27 '24 14:11 mikuso