-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Don't emit end events after error events #547
Comments
@brianc any interest? |
If that's how node core event emitters behave, then I think this is definitely how node-postgres should behave as well. You want to whip up a PR or have me add it in? I'm trying to get the [email protected] release out and this is a breaking change, so I have it targeted for that release. |
Just made that change & all the tests pass - sooo that's good. Adding a test for the change & pushing it up as a PR. Going to ship this today. 👊 |
Awesome, thank you! I would have been happy to make the change, thanks for taking care of it. Leaving this open for now, but feel free to close it when you land that change. |
I always find it a little surprising/frustrating that Query objects (and maybe other types) can emit both 'error' and 'end' events. In most event emitters 'error' events are also effectively end events. I often end up with patterns like this.
Because Query objects will emit both of those events in the case of an error, that becomes rather problematic and you end up having to do something like.
Or maintain state about errors or something. In any case, it makes handling errors a little non-standard. I'd love to change the either 'error' or 'end' is emitted, but never both.
What do you think?
The text was updated successfully, but these errors were encountered: