diff --git a/stream.go b/stream.go index c72aac5877ce..8285c8891010 100644 --- a/stream.go +++ b/stream.go @@ -534,6 +534,10 @@ func (cs *clientStream) commitAttempt() { // the error that should be returned by the operation. If the RPC should be // retried, the bool indicates whether it is being retried transparently. func (cs *clientStream) shouldRetry(err error) (bool, error) { + if cs.finished || cs.committed { + // RPC is finished or committed; cannot retry. + return false, err + } if cs.attempt.s == nil { // Error from NewClientStream. nse, ok := err.(*transport.NewStreamError) @@ -559,10 +563,6 @@ func (cs *clientStream) shouldRetry(err error) (bool, error) { return true, nil } } - if cs.finished || cs.committed { - // RPC is finished or committed; cannot retry. - return false, err - } // Wait for the trailers. unprocessed := false if cs.attempt.s != nil {