Skip to content

Conversation

@merolish
Copy link
Contributor

Summary

The jrpc handler is a bit tricky in terms of result chaining and sending responses. This is I think a sane refactor to handle batch updates in those cases where the publisher wants a response.

Rationale

MIAX testing feedback.

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

@vercel
Copy link

vercel bot commented Nov 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
api-reference Ready Ready Preview Comment Nov 13, 2025 4:58pm
component-library Ready Ready Preview Comment Nov 13, 2025 4:58pm
developer-hub Ready Ready Preview Comment Nov 13, 2025 4:58pm
entropy-explorer Ready Ready Preview Comment Nov 13, 2025 4:58pm
insights Ready Ready Preview Comment Nov 13, 2025 4:58pm
proposals Error Error Nov 13, 2025 4:58pm
staking Error Error Nov 13, 2025 4:58pm

},
)
.await?;
anyhow::bail!("Error processing batch update: {:?}", err);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this bail! may not be needed here. It's not present in handle_push_update. Looks like it will result in client receiving two error responses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good point.

Comment on lines 259 to 272
if let Err(err) = lazer_publisher
.push_feed_update(request_params.clone().into())
.await
{
debug!("error while sending updates: {:?}", err);
send_json(
sender,
&JrpcErrorResponse {
jsonrpc: JsonRpcVersion::V2,
error: JrpcError::SendUpdateError(request_params.clone()).into(),
id: request_id.clone(),
},
)
.await?;
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole body of the for loop can be moved out into a function to avoid code duplication with handle_push_update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, just need to come up with a distinction between "this update failed to send" and "sending the error response itself failed" which has a distinction here. Errors upon errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored.

batch_request: &[FeedUpdateParams],
request_id: JrpcId,
) -> anyhow::Result<()> {
for request_params in batch_request.iter() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for request_params in batch_request.iter() {
for request_params in batch_request {

@merolish merolish dismissed Riateche’s stale review November 13, 2025 19:50

Reviewed and approved by Keyvan.

@merolish merolish merged commit 5d11cbc into main Nov 13, 2025
8 of 10 checks passed
@merolish merolish deleted the mike/agent-batch-response branch November 13, 2025 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants