Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit errors only when listeners are present #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

alexpenev-s
Copy link
Owner

No description provided.

@dotchev
Copy link

dotchev commented Nov 23, 2016

Will this fix issue SAP#64?

@@ -223,8 +223,10 @@ Connection.prototype._addListeners = function _addListeners(socket) {
if (cb) {
self._state.receive = null; // a callback should be called only once
cb(err);
} else {
} else if (self.listenerCount('error')) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listenerCount is present since v3.2.0, see https://nodejs.org/api/events.html#events_emitter_listenercount_eventname
package.json says "node": ">= 0.12"
we could do it like this
self.listenerCount && self.listenerCount('error') || self.listeners('error').length

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants