David Clark
David Clark

Reputation: 1

How to get Google Cloud Storage SDK for Node.js to automatically retry, and check whether it is?

I'm using the Google Cloud Storage SDK for Node.js, and I'm trying to configure its automatic retries. I just watched a simple GET request fail with no retries, so I'm wondering what I could be doing wrong.

I know the GET request was not retried because I'm tracing HTTP requests with open telemetry, and I only saw one fail, then the SDK gave up and threw an error. The error's status code is 503, so I'd expect a retry.

I have looked at documentation, like this doc about the retry strategy and this example, and I don't see what I'm doing wrong.

Here's the configuration I have right now:

import { Storage } from '@google-cloud/storage';
import { util as GcpUtil } from '@google-cloud/common';

new Storage({
  retryOptions: {
    autoRetry: true,
    idempotencyStrategy: IdempotencyStrategy.RetryConditional,
    retryableErrorFn: (err) => {
      const isRetryable = GcpUtil.shouldRetryRequest(err);
      // Some logging ...
      return isRetryable;
    },
  },
});

I am not seeing my logs, suggesting retryableErrorFn is not being called, and nothing else seems to be used in its place to determine that a retry should happen.

I have also tried this without specifying retryableErrorFn, and also seen no retries on simple GET requests.

Upvotes: 0

Views: 61

Answers (0)

Related Questions