-
Notifications
You must be signed in to change notification settings - Fork 308
fix(pyth-lazer-agent): Only send one success response per batch update #3186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| }, | ||
| ) | ||
| .await?; | ||
| anyhow::bail!("Error processing batch update: {:?}", err); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good point.
| 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?; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for request_params in batch_request.iter() { | |
| for request_params in batch_request { |
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?