Skip to content

Commit ef7cd4e

Browse files
authored
refactor(fetcher): migrate withRetries to waitUntil (#6429)
## Problem Recently a [PR](https://github.com/aws/aws-toolkit-vscode/pull/6387/files#diff-c0100187095b7c009b33063c21a517248290b37d02ef10e9370d28cd3ed5d1ea) on master combined `waitUntil` with `withRetries`. Once master merged into feature branch, it caused this case to start erroring. Leading to the following: ``` npm error src/shared/resourcefetcher/httpResourceFetcher.ts(164,16): error TS2304: Cannot find name 'withRetries'. ``` ## Solution - migrate to `waitUntil` in the same fashion as the PR. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 74eabe9 commit ef7cd4e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/core/src/shared/resourcefetcher/httpResourceFetcher.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class HttpResourceFetcher implements ResourceFetcher<Response> {
135135
}
136136

137137
export class RetryableResourceFetcher extends HttpResourceFetcher {
138-
private readonly retryNumber: number
138+
private readonly requestTimeoutMs: number
139139
private readonly retryIntervalMs: number
140140
private readonly resource: string
141141

@@ -155,13 +155,13 @@ export class RetryableResourceFetcher extends HttpResourceFetcher {
155155
showUrl,
156156
timeout,
157157
})
158-
this.retryNumber = retryNumber
158+
this.requestTimeoutMs = retryNumber * retryIntervalMs
159159
this.retryIntervalMs = retryIntervalMs
160160
this.resource = resource
161161
}
162162

163163
fetch(versionTag?: string) {
164-
return withRetries(
164+
return waitUntil(
165165
async () => {
166166
try {
167167
return await this.getNewETagContent(versionTag)
@@ -171,8 +171,9 @@ export class RetryableResourceFetcher extends HttpResourceFetcher {
171171
}
172172
},
173173
{
174-
maxRetries: this.retryNumber,
175-
delay: this.retryIntervalMs,
174+
timeout: this.requestTimeoutMs,
175+
interval: this.retryIntervalMs,
176+
retryOnFail: true,
176177
}
177178
)
178179
}

0 commit comments

Comments
 (0)