Skip to content

Commit 25111ba

Browse files
committed
addressed comments
1 parent bfb03f0 commit 25111ba

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

packages/amazonq/test/e2e/inline/inline.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Amazon Q Inline', async function () {
2424
const waitOptions = {
2525
interval: 500,
2626
timeout: 10000,
27-
retryOnFail: () => true,
27+
retryOnFail: () => false,
2828
}
2929

3030
before(async function () {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ export class HttpResourceFetcher implements ResourceFetcher<Response> {
120120
timeout: 3000,
121121
interval: 100,
122122
backoff: 2,
123-
retryOnFail: (error: Error | undefined) => {
124-
// Only stops retry when the user intentionally canceled the operation.
123+
retryOnFail: (error?: Error) => {
124+
// Retry unless the user intentionally canceled the operation.
125125
return error ? !isUserCancelledError(error) : true
126126
},
127127
}

packages/core/src/shared/utilities/timeoutUtils.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,16 @@ interface WaitUntilOptions {
222222
/** A backoff multiplier for how long the next interval will be (default: None, i.e 1) */
223223
readonly backoff?: number
224224
/**
225-
* Call back, true when the function should be retried on failure.
225+
* Callback, returns `true` when the function should be retried on failure.
226+
*
226227
* Example usage:
227-
* - () => boolean if the retry logic is "constant"
228-
* - (error) => { error ? retryOnError(error) : boolean }
229-
* where retryOnError determines what errors to retry, and the boolean is for base case when there's no error (undefined)
230-
* 'truthy' arg is ignored
231-
* If the timeout is reached it throws the last error
232-
* Default to false
228+
* - `() => boolean` if the retry logic is "constant".
229+
* - `(error) => { error ? retryOnError(error) : boolean }`
230+
* where `retryOnError` determines what errors to retry, and the boolean is for the base case when there's no error (undefined).
231+
*
232+
* The `truthy` argument is ignored.
233+
* If the timeout is reached, it throws the last error.
234+
* Defaults to `false`.
233235
*/
234236
readonly retryOnFail?: (error: Error | undefined) => boolean
235237
}
@@ -248,7 +250,7 @@ export const waitUntilDefaultInterval = 500
248250
*/
249251
export async function waitUntil<T>(
250252
fn: () => Promise<T>,
251-
options: WaitUntilOptions & { retryOnFail: (error: Error | undefined) => boolean }
253+
options: WaitUntilOptions & { retryOnFail: (error?: Error) => boolean }
252254
): Promise<T>
253255

254256
export async function waitUntil<T>(

packages/core/src/test/shared/utilities/timeoutUtils.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ export const timeoutUtilsDescribe = describe('timeoutUtils', async function () {
401401

402402
const res = waitUntil(fn, {
403403
retryOnFail: (error) => {
404-
return error ? error.message === 'Retry error' : false
404+
return error?.message === 'Retry error'
405405
},
406406
})
407407

@@ -421,7 +421,7 @@ export const timeoutUtilsDescribe = describe('timeoutUtils', async function () {
421421
const res = assert.rejects(
422422
waitUntil(fn, {
423423
retryOnFail: (error) => {
424-
return error ? error.message === 'Retry error' : true
424+
return error?.message === 'Retry error'
425425
},
426426
}),
427427
(e) => e instanceof Error && e.message === 'Last error'

0 commit comments

Comments
 (0)