go
network_error
ai_generated
true
rpc error: code = Canceled desc = context canceled
ID: go/grpc-canceled-by-client
80%Fix Rate
87%Confidence
0Evidence
2024-03-27First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| google.golang.org/grpc 1.48+ | active | — | — | — |
Root Cause
The client canceled the RPC (via context cancel, HTTP/2 RST_STREAM, or parent context timeout) before the server finished.
generic中文
客户端在服务端完成前取消了 RPC(通过 context cancel、HTTP/2 RST_STREAM 或父上下文超时)。
Workarounds
-
90% success
Check ctx.Err() in the server handler and exit early: select { case <-ctx.Done(): return nil, status.FromContextError(ctx.Err()).Err() default: } // continue processing -
85% success
Distinguish client cancel from server-side timeout by inspecting the parent context; treat codes.Canceled as INFO in logs and metrics.
Dead Ends
Common approaches that don't work:
-
80% fail
If the caller intentionally canceled (e.g., user closed the page), retrying wastes resources.
-
85% fail
Canceled is a normal client behavior; alerting creates noise.