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

Catch event handler error #86

Merged
merged 4 commits into from
Jul 17, 2018
Merged

Conversation

monkbroc
Copy link
Member

@monkbroc monkbroc commented Jul 2, 2018

The SSE stream parser does not handle errors well. If a user event handler throws an exception, the error will be silently ignored and the parser will stop parsing future events. Parsing errors in the JSON data will also be silently ignored and the parser will stop parsing future events.

TODO: there parser has no tests. We should add EventStream.spec.js to test the implementation.

Fixes #15 and fixes #62

@monkbroc monkbroc requested a review from busticated July 2, 2018 14:56
@coveralls
Copy link

coveralls commented Jul 2, 2018

Coverage Status

Coverage decreased (-0.3%) to 73.86% when pulling ab7a2d6 on feature/catch-event-handler-error into 74e67dd on master.

@monkbroc monkbroc mentioned this pull request Jul 2, 2018
if (this.eventName !== 'event') {
this.emit(this.eventName, event);
}
this.emit('event', event);
Copy link
Contributor

Choose a reason for hiding this comment

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

i realize this isn't a change you introduced but i'm wondering why the if statement here is needed at all?

e.g. simply:

this.emit(this.eventName, event);

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this would emit the Node event twice if the Particle event was name event. It's a bad pattern to emit a Node event from the Particle event name. The Particle event error also clashes with the Node error event.

Copy link
Contributor

Choose a reason for hiding this comment

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

got it 👍

@monkbroc monkbroc force-pushed the feature/catch-event-handler-error branch from a36b356 to e0eb866 Compare July 17, 2018 15:59
@monkbroc monkbroc merged commit c34e869 into master Jul 17, 2018
@monkbroc monkbroc deleted the feature/catch-event-handler-error branch July 17, 2018 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants