-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[devicetrust] fix: handle server errors in bi-directional streams #44677
Conversation
lib/devicetrust/authn/authn.go
Outdated
// The client only sees the server's error when it tries to read from the stream. | ||
// This function repeatedly calls Recv to surface the first error encountered. | ||
// Use this function when the stream's content is irrelevant and only the error matters. | ||
func consumeStreamToError(sendErr error, stream devicepb.DeviceTrustService_AuthenticateDeviceClient) error { |
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 defined this function 3 times to avoid making any of these functions publicly available in api
to avoid people incorrectly using them.
If you guys prefer it to be moved, I am ok with it
Moved to api/utils since there are tons of bad usage in our codebase
Fix an edge case in the devicetrust gRPC bi-directional stream handler where the stream could terminate with an error after the last client `Recv` call but before the next `Send` call. Previously, this scenario caused the `Send` method to return an `io.EOF` error, which indicated that the connection was terminated but did not reveal any errors returned by the server. This update ensures that the client continues to consume the stream until an error is returned, allowing for proper error handling and more robust stream management. Signed-off-by: Tiago Silva <[email protected]>
61e4ff8
to
1d57fab
Compare
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.
Thanks, Tiago.
Fix an edge case in the devicetrust gRPC bi-directional stream handler where the stream could terminate with an error after the last client
Recv
call but before the nextSend
call. Previously, this scenario caused theSend
method to return anio.EOF
error, which indicated that the connection was terminated but did not reveal any errors returned by the server. This update ensures that the client continues to consume the stream until an error is returned, allowing for proper error handling and more robust stream management.Changelog: Ensure Device Trust clients correctly handle server errors on abruptly terminated streams.