+Cancelling the request mid-retry keeps the failure that triggered the backoff. If the context is cancelled (or its deadline expires) while the retry loop is sleeping between attempts, the returned error wraps both the last transport or HTTP error that caused the retry and the cancellation cause, formatted as `<last error> (cancelled while retrying: <context error>)`. `errors.Is(err, context.Canceled)` and `errors.Is(err, context.DeadlineExceeded)` still report the cancellation, and the underlying HTTP status stays readable in the error message and through `errors.Is` / `errors.As`. Bounding a slow request by cancelling its context no longer collapses every failure into a bare `context canceled` / `context deadline exceeded` and hides why the request was being retried.
0 commit comments