-
Notifications
You must be signed in to change notification settings - Fork 158
Description
I think this check in http_p.js should be improved as it may result in not re-emitting an error event.
this._events.error
is either an Array (if more then 1 listener is installed) or Function
(only 1 listener installed).
Currently this check works because the installed listener errorCapturer
has exactly 1 named parameter therefore errorCapturer.length === 1
.
But if there is a module used which wraps the installed listeners (e.g. for CLS,...) or if once
is used to install the listener this is broken. Besides that it relies on internals of EventEmitter
(the _events
field`).
I recommend to use the public EventEmitter
Api to check that <= 1 listener is installed.
Recent NodeJs versions allow to listen on errorMonitor to avoid the need to re-emit in case only 1 listener is present at all.