mcollina / mqemitter-redis

Redis-powered MQEmitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Emitting the 'error' throws an unhandled error

leobudima opened this issue · comments

In PR: #3 , the 'error' events are emitted using the EventEmitter - which, by default EE behavior, throws the error: https://nodejs.org/api/events.html.

const myEmitter = new MyEmitter();
myEmitter.emit('error', new Error('whoops!'));
// Throws and crashes Node.js

In case of using mqemitter-redis indirectly, like in my case with multines, this cannot be caught, so it causes issues - for example, Redis disconnection, instead of automated reconnect, crashes Hapi.

If emitted events would be callled "pubError" and "subError" like in the original PR submission (or anything else, if more sensible), the issue would be solved.

Would you like to send a PR?