go network_error ai_generated true

rpc error: code = DeadlineExceeded desc = context deadline exceeded

ID: go/grpc-deadline-exceeded-long-running

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-07-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.x active

Root Cause

The client set a deadline (via context.WithTimeout or context.WithDeadline) for the RPC, but the server took longer to respond than the allowed time.

generic

中文

客户端为 RPC 设置了截止日期(通过 context.WithTimeout 或 context.WithDeadline),但服务器响应时间超过了允许的时间。

Workarounds

  1. 70% success
    Profile the handler and reduce database queries or external calls.
  2. 80% success
    ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second); defer cancel(); for i := 0; i < 3; i++ { err := client.Call(ctx, ...); if err == nil { break }; time.Sleep(time.Duration(i)*time.Second) }

Dead Ends

Common approaches that don't work:

  1. 40% fail

    This may hide the underlying performance issue and cause long hangs.

  2. 90% fail

    The server may have partially processed the request, leading to inconsistency.