Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

retryOptions.retryableErrorFn called with 200 ok for resumable upload #1851

@benogle

Description

@benogle

Environment details

  • OS: node14.18.2-alpine3.12 (docker)
  • Node.js version: 14.18.2
  • npm version: 6.14.15
  • @google-cloud/storage version: 5.18.3

Steps to reproduce

retryOptions.retryableErrorFn is often called with a plain object containing code: 200.

const storage = new Storage({
  retryOptions: {
    autoRetry: true,
    retryDelayMultiplier: 2,
    totalTimeout: 600,
    maxRetryDelay: 60,
    maxRetries: 10,
    idempotencyStrategy: IdempotencyStrategy.RetryAlways,
    retryableErrorFn: (err) => {
      console.log(err)

      // !!
      // err is often a plain object:
      // { code: 200, message: 'OK', name: 'OK' }

      return true
    },
  },
})
const cloudFile = storage.bucket('our-bucket').file('somename.zip')
const result = await cloudFile.save(buffer, {
  // `resumable: true` seems to be the key to triggering this.
  // We only set `resumable: true` with files > 10mb.
  resumable: true,

  gzip: true,
  metadata: {
    cacheControl: 'no-cache',
  },
  predefinedAcl: 'projectPrivate',
})

If we ignore the 200s in retryableErrorFn, cloudFile.save ultimately succeeds, but it took a while for us to discover we could safely ignore them as we could only reproduce this in production. retryableErrorFn is called in the upload stream's error event, obviously extremely confusing that it's called with a code 200.

If we retry the 200s, it retries until it eventually fails with:

The offset is lower than the number of bytes written. The server has 0 bytes and while XXXX bytes has been uploaded - thus XXXX bytes are missing. Stopping as this could result in data loss. Initiate a new upload to continue.

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/nodejs-storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions