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

Error events are lost of the EventEmitter is not properly initialized #264

Open
fresheneesz opened this issue Jun 16, 2020 · 2 comments
Open

Comments

@fresheneesz
Copy link
Contributor

I had a situation where something was inheriting from EventEmitter, however the constructor forgot to call the superclass constructor and no event listeners were added on that emitter (which would also have initialized the emitter). So on line 932, it simply returns false when an error is raised. This should be updated to throw the error if an error is being raised, rather than silently ignoring it.

@DigitalBrainJS
Copy link
Collaborator

DigitalBrainJS commented Jun 17, 2020

Hmm, I'm not sure if this is a real bug since this issue does not actually arise if the constructor chain was called properly. With ES6 classes, which are currently the main way of inheritance for typical users, it's not possible to inherit a class without calling its super constructor. Generally a class should not guarantee proper work if its constructor has not been called.

@fresheneesz
Copy link
Contributor Author

I think that's usually a reasonable take. However, usually when something isn't properly set up, an error will happen when methods are called, etc. In this case, it silently fails. And the fix is pretty easy - just throw an error if its not properly set up instead of returning false. Is there a reason its returning false instead of throwing an error?

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

2 participants