Skip to content

Conversation

@Nana-EC
Copy link
Contributor

@Nana-EC Nana-EC commented Nov 29, 2025

Reviewer Notes

Currently the handler closes both the stream and connection when handling BEHIND code.
However, the expectation is the publisher would follow up either with more appropriate block items or a TOO_FAR_BEHIND.
When the publisher does it experiences a socket closed exception

  • Update BatchHandleResult to separate shutdown, reset and close stream
  • Update handleBlockActionResult() to manage 3 cases in a more coordinate fashion and not call either unnecessarily
  • Add API Test scenario that shows publisher no longer observes socket exception

Partially address #1914 but does not attempt to fix the protocol definition as that requires CN coordination and larger changes

Related Issue(s)

Use keywords Fix, Fixes, Fixed, Close, Closes, Closed, Resolve, Resolves, Resolved
to connect an issue to be closed by this pull request.

@Nana-EC Nana-EC added this to the 0.24.0 milestone Nov 29, 2025
@Nana-EC Nana-EC self-assigned this Nov 29, 2025
@Nana-EC Nana-EC added Bug A error that causes the feature to behave differently than what was expected based on design docs Block Node Issues/PR related to the Block Node. labels Nov 29, 2025
Copy link
Contributor

@ata-nas ata-nas left a comment

Choose a reason for hiding this comment

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

Just some preliminary notes to think about.

Comment on lines +551 to +560
} else {
// close stream leaving connection open for subsequent publishers calls
if (handleResult.shouldCloseStream()) {
replies.onComplete();
}

// clean up handler state
if (handleResult.shouldReset()) {
resetState();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if these should be in an else. All these booleans should probably run if they are all true.

} else {
// close stream leaving connection open for subsequent publishers calls
if (handleResult.shouldCloseStream()) {
replies.onComplete();
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if that is the only thing we need to do to close the stream. I remember there were some changes recently that allow us to actually close the stream completely.

assertThat(tooFarBehindResponseObserver.getOnErrorCalls()).isEmpty();
assertThat(tooFarBehindResponseObserver.getOnSubscriptionCalls()).isEmpty();
assertThat(tooFarBehindResponseObserver.getOnCompleteCalls().get()).isEqualTo(1);
assertThat(tooFarBehindResponseObserver.getOnErrorCalls().size()).isEqualTo(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just FYI, assertj has some conveniences for zero values, some other very frequently used. So we can do "assertThat(number).isZero();". Non-blocking nit. On another note, instead of calling Collection#size and checking if it is zero, we could simply call assertThat(collection).isEmpty(); as seen in L:618. Again, totally non-blocking nit.

@jsync-swirlds jsync-swirlds self-requested a review December 1, 2025 15:58
@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../block/node/stream/publisher/PublisherHandler.java 84.61% 2 Missing ⚠️
@@             Coverage Diff              @@
##               main    #1915      +/-   ##
============================================
- Coverage     79.48%   79.09%   -0.39%     
- Complexity     1193     1200       +7     
============================================
  Files           128      130       +2     
  Lines          5684     5770      +86     
  Branches        610      616       +6     
============================================
+ Hits           4518     4564      +46     
- Misses          887      924      +37     
- Partials        279      282       +3     
Files with missing lines Coverage Δ Complexity Δ
.../block/node/stream/publisher/PublisherHandler.java 89.54% <84.61%> (+0.77%) 57.00 <0.00> (+1.00)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AlfredoG87 AlfredoG87 modified the milestones: 0.24.0, 0.25.0 Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Block Node Issues/PR related to the Block Node. Bug A error that causes the feature to behave differently than what was expected based on design docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants