Fix gRPC client error handling and health check timeout context#23
Open
alienx5499 wants to merge 1 commit intodrand:masterfrom
Open
Fix gRPC client error handling and health check timeout context#23alienx5499 wants to merge 1 commit intodrand:masterfrom
alienx5499 wants to merge 1 commit intodrand:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two issues in
grpc/grpc.go:NewClientignores error fromgrpc.NewClient— if the call fails, the error is logged but not returned. The function continues with a nilconn, andproto.NewPublicClient(conn)will panic.Health check retry bypasses timeout — in
Check(), the first attempt usestctx(with timeout), but the retry falls back to the originalctx(no timeout). This means the retry can hang indefinitely, defeating the configuredhealthTimeout.Changes
grpc/grpc.gogrpc.NewClientinstead of continuing with a nil connection.tctx(timeout context) for the health check retry instead of the parentctx.grpc/grpc_test.goTestNewClient_InvalidAddress— verifiesNewClientreturns an error for invalid addresses.TestCheck_CancelledContext— verifiesCheckrespects context cancellation.Testing
go test ./... -timeout 60sAll existing and new tests pass. No behavior changes for valid inputs.