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
Make event handling fallible #2995
base: main
Are you sure you want to change the base?
Conversation
Previously, we would require our users to handle all events successfully inline or panic will trying to do so. If they would exit the `EventHandler` any other way we'd forget about the event and wouldn't replay them after restart. Here, we implement fallible event handling, allowing the user to return `Err(())` which signals to our event providers they should abort event processing and replay any unhandled events later (i.e., in the next invocation).
|
||
for event in events.into_inner() { | ||
handler(event).await | ||
// Ignore any errors as onion messages are best effort anyways. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be up for discussion? Do we want to replay OM events also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should consider it. Once we do #2973 we'll be using this for onion messages that are destined for some "customer" of the node, so they probably kinda care about being as reliable as possible up to DoS issues.
I believe our recommendation was always to simply loop trying to handle the event until they succeed, which is basically what we're doing here for them :) As to the code here, I think we should make more clear in the interface the event will be replayed, eg by making the error variant a unit struct called |
Closes #2490.
Previously, we would require our users to handle all events successfully inline or panic will trying to do so. If they would exit the
EventHandler
any other way we'd forget about the event and wouldn't replay them after restart.Here, we implement fallible event handling, allowing the user to return
Err(())
which signals to our event providers they should abort event processing and replay any unhandled events later (i.e., in the next invocation).TODO:
Err(())
.