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

Erroring in event handlers #4130

Closed
frankiebee opened this issue Apr 29, 2018 · 4 comments
Closed

Erroring in event handlers #4130

frankiebee opened this issue Apr 29, 2018 · 4 comments

Comments

@frankiebee
Copy link
Contributor

event emitters fired in catches will run the listeners in the context of the catch. If it fails, however unrelated to the the function that fires the event it will stop the execution of the catch. this can cause serious bugs such as issue #3881 to not be easy to identify. And the error messages they produce can be unrelated to the reason the method failed in the first place. and in the case of txController#approveTransaction a failed to post to sentry is neither a useful error for the dapp nor the reason why the method failed. One short term solution is to wrap event emitting methods in a setTimeout so the listeners are executing outside the context of the catch. But the better long term solution is to not have events emitted in catch this of course will require a rewrite of the architecture of txController.

@kumavis
Copy link
Member

kumavis commented Apr 29, 2018

we can wrap our emits in try-catch's
this is a design flaw in eventemitters
i think dtar said we should use streams instead of event emitters (just push all events through streams, filter for what event we care about)
we can solve niceties likeonce with some abstractions

@frankiebee
Copy link
Contributor Author

if we run it in a try catch what am i going to do with the error? i can log it but if the error is related to posting to sentry and i error in the catch cause of logging we run into the same problem the error is thrown in the catch throwing in the catch above it silently killing approve transaction

@kumavis
Copy link
Member

kumavis commented Apr 30, 2018

yeah we can log.error(err) and drop it then continue normally

@kumavis kumavis changed the title emitting events in catches Erroring in event handlers May 1, 2018
@bdresser bdresser added this to the Sprint 08 [7.23 - 8.3] milestone Jul 23, 2018
@bdresser
Copy link
Contributor

closing since #4131 was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants