misc: handle receiver errors in the event bus #367
+86
−49
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR, we handle errors coming from the event bus receiver. It also changes the way we behave in case of
Lagged
error.There is 2 possible errors return from the receiver :
Lagged
- In this scenario we print a warning message saying that messages have been skipped and we keep reading from the receiver for new messages. This error should only happened when handling events that are p2p. If a peer fill the channel older messages will be dropped and newer will be read. The limit is 2000 events so it will limit the number of tasks being spawned at once avoiding risk of DoS by a peer.Closed
- This error will happen if there is no more available sender. It shouldn't happen normally. In this case we print a warning message and leave function.In the scenario the event bus is handling event from the runtime, we are assuming that the limit 2000 is more than enough to never fill the channel because we can handle events faster that the blockchain can accept new transactions.