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

Unable to propagate error event from EventEmitter2 #7

Open
agirorn opened this issue Dec 4, 2017 · 2 comments
Open

Unable to propagate error event from EventEmitter2 #7

agirorn opened this issue Dec 4, 2017 · 2 comments

Comments

@agirorn
Copy link

agirorn commented Dec 4, 2017

Propagate could be enhanced to work with eventemmiter2 and not fail when the error event is emitted.
Relates to EventEmitter2/EventEmitter2#215

How to repoduce
``js
#!/usr/bin/env node

const EventEmitter2 = require('eventemitter2').EventEmitter2;
const propagate = require('propagate');

const source = new EventEmitter2();
const dest = new EventEmitter2();

propagate(source, dest);

dest.on('error', (error) => { console.log('got error event', error); });

console.log('sending error event');
try {
source.emit('error', 'The error data');
} catch(e) {
console.log('caught error', e);
}


```shell
sending error event
caught error Error: Uncaught, unspecified 'error' event.
    at EventEmitter.emit (/home/agirorn/tmp/test-propagate-eventemitter2/node_modules/eventemitter2/lib/eventemitter2.js:398:15)
    at EventEmitter.source.emit (/home/agirorn/tmp/test-propagate-eventemitter2/node_modules/propagate/index.js:19:13)
    at Object.<anonymous> (/home/agirorn/tmp/test-propagate-eventemitter2/test.js:15:10)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:383:7)
➜  test-propagate-eventemitter2

expected result

sending error event
got error event The error data
@pgte
Copy link
Member

pgte commented Dec 4, 2017

Gladly accepting code contributions :)

@DigitalBrainJS
Copy link

You should have at least one error listener in the source emitter to avoid throwing this error.
Since 6.1.0 we have the ignoreErrors option for the EventEmitter2 constructor to disable this behavior.

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

No branches or pull requests

3 participants