Skip to content

Conversation

dapplion
Copy link
Collaborator

Issue Addressed

Noted that while serving ResResp BlobsByRoot for some errors we properly terminate the stream with an error, while other don't. I believe this is a typo, and caused by the fact that every return statement from the function must include an outbound event. This requirement is prone to typos, and may not be apparent to a contributor.

Proposed Changes

Wrap ReqResp handling functions with a terminate_response_* function that forces every handler call to terminate properly:

  • If multi-response: with either a stream termination or an error
  • If single response: with either a single item or an error

My hope is that future contributors will just extend this PR's pattern and not let streams hanging.

Additional Info

I can't cover the blocks_by* methods are their termination is handled on an spawned function. @michaelsproul any way to get the return value from some variant of executor.spawn to be able to change the signature of handle_blocks_by_range_request to Result<StreamTerminator, RPCError>?

Copy link
Member

@realbigsean realbigsean left a comment

Choose a reason for hiding this comment

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

Big fan of the change

@realbigsean realbigsean added the ready-for-merge This PR is ready to merge. label Apr 12, 2024
@dapplion dapplion requested a review from realbigsean April 12, 2024 14:31
@realbigsean
Copy link
Member

@Mergifyio queue

Copy link

mergify bot commented Apr 12, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at 116a55e

mergify bot added a commit that referenced this pull request Apr 12, 2024
@mergify mergify bot merged commit 116a55e into sigp:unstable Apr 12, 2024
@dapplion dapplion deleted the reqresp-termination branch April 13, 2024 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge This PR is ready to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants