Extend EOF Error Handling to All Client-Side Streamers
Background
In merge request !7137 (merged), we implemented proper error handling for some of the client-side streamers that use the Chunker pattern. When a client receives an io.EOF
error during a Send()
operation, it now calls Recv()
on the stream to retrieve the actual error status instead of returning the opaque EOF error.
However, this fix was only applied to specific client-side streamers that use the Chunker pattern. We need to extend this pattern to all other client-side streamers to ensure consistent error handling throughout the codebase.
Problem
When using gRPC streaming, the client may receive an io.EOF
error that doesn't provide the actual error details. As documented in the gRPC API:
On error, SendMsg aborts the stream. If the error was generated by the client, the status is returned directly; otherwise, io.EOF is returned and the status of the stream may be discovered using Recv.
Currently, many client-side streamers don't follow this pattern and simply return the io.EOF
error without calling Recv()
to get the actual error status, resulting in:
- Opaque error messages that don't provide useful information
- Difficulty in debugging server-side issues
- Inconsistent error handling across the codebase
Proposed Solution
- Identify all client-side streamers with or without Chunker pattern, which are not handling io.EOF yet.
- Modify each streamer to properly handle
io.EOF
errors by callingRecv()
to get the actual error status - Ensure consistent error message formatting across all streamers
Implementation Details
For each client-side streamer, implement error handling similar to what was done in !7137 (merged):
// Example implementation pattern
err := stream.Send(&request)
if err != nil {
if errors.Is(err, io.EOF) {
if _, recvErr := stream.Recv(); recvErr != nil {
return recvErr
}
}
return err
}
Files to Modify
Identify all client-side streamers in:
-
internal/
directory - Any package that makes gRPC streaming calls
Testing
- Add unit tests that simulate server-side errors during streaming
- Verify that the actual error message is propagated to the client
- Ensure error messages are consistent and informative