pm2-io-apm
pm2-io-apm copied to clipboard
PM2-io-apm always logs unhandledRejection and uncaughtException to error stream
Error stream is polluted with an intrusive log that can't be turned off or customised.
This happens when using PM2 in fork mode, as can be seen in my original issue: https://github.com/Unitech/pm2/issues/4913
Culprits:
- https://github.com/keymetrics/pm2-io-apm/blob/4.3.5/src/features/notify.ts#L137
- https://github.com/keymetrics/pm2-io-apm/blob/4.3.5/src/features/notify.ts#L139
- https://github.com/keymetrics/pm2-io-apm/blob/4.3.5/src/features/notify.ts#L166
Scouring the source code I found a couple of other places that use the console
directly.
- https://github.com/keymetrics/pm2-io-apm/blob/4.3.5/src/pmx.ts#L211
- https://github.com/keymetrics/pm2-io-apm/blob/4.3.5/src/features/events.ts#L18
- https://github.com/keymetrics/pm2-io-apm/blob/4.3.5/src/services/actions.ts#L113
- https://github.com/keymetrics/pm2-io-apm/blob/4.3.5/src/services/transport.ts#L95
- https://github.com/keymetrics/pm2-io-apm/blob/4.3.5/src/services/metrics.ts#L152
Each of these files use console
in various places, but one might argue its okay.
Unlike features/notify.ts
, these are user-land generated errors by invalid configuration and should never hit production.
Pull Request
- Do we at least add an identifiable message to both scenarios? Something along the lines of
PM2 Warning: ${error}
- Do we add a new option
logExceptions
defaulttrue
for backwards compatibility ? - Do we check number of handlers and not log if there's more than one added ? Similar to the check for process.exit:
- https://github.com/Unitech/pm2/blob/4.5.0/lib/ProcessContainer.js#L283
- https://github.com/keymetrics/pm2-io-apm/blob/4.3.5/src/features/notify.ts#L157
ping @Unitech