Skip to content

Commit

Permalink
Use client-side retries for failed uploads (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo authored Apr 7, 2023
1 parent b808197 commit 27b842f
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 56 deletions.
104 changes: 52 additions & 52 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"@types/mocha": "^10.0.1",
"@types/node": "^18.15.11",
"@types/sinon": "^10.0.13",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"@vercel/ncc": "^0.36.1",
"chai": "^4.3.7",
"eslint-config-prettier": "^8.8.0",
Expand All @@ -45,6 +45,6 @@
"prettier": "^2.8.7",
"sinon": "^15.0.3",
"ts-node": "^10.9.1",
"typescript": "^5.0.2"
"typescript": "^5.0.4"
}
}
17 changes: 16 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@

import * as path from 'path';

import { Storage, StorageOptions, PredefinedAcl, UploadOptions } from '@google-cloud/storage';
import {
IdempotencyStrategy,
PredefinedAcl,
Storage,
StorageOptions,
UploadOptions,
} from '@google-cloud/storage';
import { inParallel, toPlatformPath, toPosixPath } from '@google-github-actions/actions-utils';

import { Metadata } from './headers';
Expand Down Expand Up @@ -156,6 +162,15 @@ export class Client {
const options: StorageOptions = {
projectId: opts?.projectID,
userAgent: userAgent,

retryOptions: {
autoRetry: true,
idempotencyStrategy: IdempotencyStrategy.RetryAlways,
maxRetries: 5,
maxRetryDelay: 30,
retryDelayMultiplier: 2,
totalTimeout: 500,
},
};

this.storage = new Storage(options);
Expand Down

0 comments on commit 27b842f

Please sign in to comment.