fix: prevent pipeline errors from killing Reactor subscription#205
Merged
usmansaleem merged 4 commits intoConsensys:masterfrom Apr 1, 2026
Merged
Conversation
The pipeline used doOnNext to chain handlers, but onErrorContinue does not work reliably with doOnNext (a known Reactor limitation). When a StackOverflowError escaped a handler, it could intermittently terminate the Reactor subscription, causing the node to stop processing all subsequent incoming packets. Wrap each handler invocation in a try-catch within the pipeline so errors are contained at the handler level and never propagate to Reactor. Also add catch(Throwable) to HandshakeMessagePacketHandler for defense-in-depth, matching the existing pattern in MessagePacketHandler.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

Summary
catch(Throwable)toHandshakeMessagePacketHandlerfor defense-in-depth, matching the existing pattern inMessagePacketHandlerRoot Cause
PipelineImplchains handlers usingdoOnNext, but Reactor'sonErrorContinuedoes not reliably work withdoOnNext(a known Reactor limitation — it only supports operators likemap/flatMap). When aStackOverflowErrorescaped a handler, it could intermittently terminate the Reactor subscription, causing the node to stop processing all subsequent incoming packets.This caused the flaky timeout in
DiscoveryIntegrationTest.shouldRecoverAfterErrorWhileDecodingInboundMessage().Test plan
shouldRecoverAfterErrorWhileDecodingInboundMessagepassesNote
Medium Risk
Changes core packet processing flow by swallowing all
Throwablefrom pipeline handlers; this reduces outages but could mask bugs and alter failure semantics/logging. Also adjusts handshake error handling to drop sessions on unexpected JVM errors.Overview
Prevents individual
EnvelopeHandlerfailures from terminating the Reactor pipeline by wrapping eachdoOnNexthandler invocation in atry/catch (Throwable)and logging a warning instead of letting errors propagate.Adds defense-in-depth in
HandshakeMessagePacketHandlerby catching unexpectedThrowableduring handshake processing, logging at warn, and marking the handshake/session as failed to ensure cleanup continues even on non-Exceptionerrors.Written by Cursor Bugbot for commit bc34525. This will update automatically on new commits. Configure here.