Skip to content

Commit cff9afc

Browse files
committed
fix: tweak the delay factor when downloading artifacts
1 parent a4fa63b commit cff9afc

File tree

2 files changed

+37
-32
lines changed

2 files changed

+37
-32
lines changed

dist/cli/index.js

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/domain/artifact.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class ArtifactDownloadError extends Error {
2323
* An artifact that can be downloaded and have its integrity hash computed.
2424
*/
2525
export class Artifact {
26+
public static readonly MAX_RETRIES = 3;
2627
private _diskPath: string | null = null;
2728
public constructor(public readonly url: string) {}
2829

@@ -66,10 +67,14 @@ export class Artifact {
6667
const writer = fs.createWriteStream(dest, { flags: 'w' });
6768

6869
// Retry the request in case the artifact is still being uploaded.
69-
// Exponential backoff with 3 retries and a delay factor of 10 seconds
70-
// gives you at least 70 seconds to upload a release archive.
7170
axiosRetry(axios, {
72-
retries: 3,
71+
onRetry(retryCount, error, requestConfig) {
72+
console.error(`Failed to download artifact; ${error.message}`);
73+
console.error(
74+
`Retry atempt ${retryCount} / ${Artifact.MAX_RETRIES}...`
75+
);
76+
},
77+
retries: Artifact.MAX_RETRIES,
7378
retryDelay: exponentialDelay,
7479
shouldResetTimeout: true,
7580
retryCondition: defaultRetryPlus404,
@@ -131,7 +136,7 @@ function exponentialDelay(
131136
error: AxiosError | undefined
132137
): number {
133138
// Default delay factor is 10 seconds, but can be overridden for testing.
134-
const delayFactor = Number(process.env.BACKOFF_DELAY_FACTOR) || 10_000;
139+
const delayFactor = Number(process.env.BACKOFF_DELAY_FACTOR) || 2000;
135140
return axiosRetry.exponentialDelay(retryCount, error, delayFactor);
136141
}
137142

0 commit comments

Comments
 (0)