Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdjere committed Jan 4, 2024
1 parent 1a9782a commit 0c33f0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@ export class RetryService extends FtrService {
public async tryForTime<T>(
timeout: number,
block: () => Promise<T>,
onFailureBlock?: () => Promise<T>
onFailureBlock?: () => Promise<T>,
retryDelay?: number
) {
return await retryForSuccess(this.log, {
timeout,
methodName: 'retry.tryForTime',
block,
onFailureBlock,
retryDelay,
});
}

public async try<T>(
block: () => Promise<T>,
onFailureBlock?: () => Promise<T>,
retryDelay?: number,
timeout?: number
retryDelay?: number
) {
return await retryForSuccess(this.log, {
timeout: timeout ?? this.config.get('timeouts.try'),
timeout: this.config.get('timeouts.try'),
methodName: 'retry.try',
block,
onFailureBlock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ export const retry = async <T>({
test: () => Promise<T>;
retryService: RetryService;
retries: number;
timeout?: number;
timeout: number;
}): Promise<T | Error> => {
let retryAttempt = 0;
const response = await retryService.try(
const response = await retryService.tryForTime(
timeout,
async () => {
if (retryAttempt > retries) {
// Log error message if we reached the maximum number of retries
Expand All @@ -35,8 +36,7 @@ export const retry = async <T>({
return test();
},
undefined,
200,
timeout
200
);

// Now throw the error in order to fail the test.
Expand Down

0 comments on commit 0c33f0e

Please sign in to comment.