Summary
rawStream.handshake currently treats gRPC codes.DeadlineExceeded as a teardown artifact in isTeardownArtifact, which is too broad for the current Conn.Open path.
Because streamCtx is created with context.WithoutCancel(...) + context.WithCancel(...), teardown cancels the RPC context but does not set a deadline. A teardown-provoked gRPC outcome should therefore be codes.Canceled on this path; codes.DeadlineExceeded can represent a real server status.
Impact
When hctx has expired, handshake prefers hctx.Err() over any error classified as teardown artifact. With the current classifier, a genuine server codes.DeadlineExceeded can be dropped and replaced by context.DeadlineExceeded, changing how downstream logic classifies/retries the failure.
Proposed fix
Narrow the gRPC teardown-artifact classification to codes.Canceled (while keeping bare-context and EOF checks for non-gRPC implementations).
Test gap / follow-up
Add coverage that exercises a server status.Error(codes.DeadlineExceeded, ...) in the handshake-timeout arbitration path and asserts that the server status is preserved (not replaced by hctx.Err()).
Context
Raised during review of PR #636 as a preexisting, out-of-scope issue.
Summary
rawStream.handshakecurrently treats gRPCcodes.DeadlineExceededas a teardown artifact inisTeardownArtifact, which is too broad for the currentConn.Openpath.Because
streamCtxis created withcontext.WithoutCancel(...)+context.WithCancel(...), teardown cancels the RPC context but does not set a deadline. A teardown-provoked gRPC outcome should therefore becodes.Canceledon this path;codes.DeadlineExceededcan represent a real server status.Impact
When
hctxhas expired,handshakeprefershctx.Err()over any error classified as teardown artifact. With the current classifier, a genuine servercodes.DeadlineExceededcan be dropped and replaced bycontext.DeadlineExceeded, changing how downstream logic classifies/retries the failure.Proposed fix
Narrow the gRPC teardown-artifact classification to
codes.Canceled(while keeping bare-context and EOF checks for non-gRPC implementations).Test gap / follow-up
Add coverage that exercises a server
status.Error(codes.DeadlineExceeded, ...)in the handshake-timeout arbitration path and asserts that the server status is preserved (not replaced byhctx.Err()).Context
Raised during review of PR #636 as a preexisting, out-of-scope issue.