Open
Description
The go-grpc-middleware retry middleware has a function perCallContext
that calls context.WithTimeout
and ignores the returned cancel
function. According to the context.WithTimeout
docs:
// Canceling this context releases resources associated with it, so code should
// call cancel as soon as the operations running in this Context complete:
//
// func slowOperationWithTimeout(ctx context.Context) (Result, error) {
// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
// defer cancel() // releases resources if slowOperation completes before timeout elapses
// return slowOperation(ctx)
// }
Here is the offending code in https://github.com/grpc-ecosystem/go-grpc-middleware/blob/master/retry/retry.go#L290
func perCallContext(parentCtx context.Context, callOpts *options, attempt uint) context.Context {
ctx := parentCtx
if callOpts.perCallTimeout != 0 {
ctx, _ = context.WithTimeout(ctx, callOpts.perCallTimeout)
}
...
Metadata
Metadata
Assignees
Labels
No labels