Skip to content

sendAndRetry(): context error is not being returned when context is canceled #1685

@matheuscscp

Description

@matheuscscp

Environment details

  • Programming language: Go
  • OS: Linux
  • Language runtime version: 1.18.5
  • Package version: google.golang.org/api v0.66.0 and cloud.google.com/go/storage v1.19.0

Steps to reproduce

  1. Run an idempotent operation like this (creating a file in GCS):

bkt.Object(dstPath).If(storage.Conditions{DoesNotExist: true}).NewWriter(ctx).Write(b)

  1. Make the server return a 503, causing the underlying call of sendAndRetry() to fail and block until it's time for a second attempt.
  2. Cancel ctx before the second attempt.
  3. Observe that the error returned by .Write() will contain the 503 error message but not context.Canceled.

This is misleading because it makes it look like the error that caused the operation to fail and return was the 503 error from the server, but what actually caused the operation to fail and return was my code canceling the context. This is confusing because the docs tell you that the library will retry idempotent operations upon 503, so it's really weird seeing the operation return the 503 error.

Metadata

Metadata

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions