Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mergeAxeResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { getBrowserToRun, getPlaywrightLaunchOptions } from './constants/common.
import {
getWcagPassPercentage,
getProgressPercentage,
retryFunction,
zipResults,
getIssuesPercentage,
getWcagCriteriaMap,
Expand All @@ -40,6 +39,7 @@ import {
getStoragePath,
getUserDataTxt,
getVersion,
retryFunction,
} from './utils/index.js';
import { consoleLogger, silentLogger } from './logs.js';
import itemTypeDescription from './constants/itemTypeDescription.js';
Expand Down
15 changes: 0 additions & 15 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -863,21 +863,6 @@ export const zipResults = async (zipName: string, resultsPath: string): Promise<
});
};

export const retryFunction = async <T>(func: () => Promise<T>, maxAttempt: number): Promise<T> => {
let attemptCount = 0;
while (attemptCount < maxAttempt) {
attemptCount += 1;
try {
// eslint-disable-next-line no-await-in-loop
const result = await func();
return result;
} catch (error) {
// do nothing, just retry
}
}
throw new Error('Maximum number of attempts reached');
};

/**
* Determines which WCAG criteria might appear in the "needsReview" category
* based on axe-core's rule configuration.
Expand Down
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { default as getCurrentDate } from './getCurrentDate.js';
export { default as getStoragePath } from './getStoragePath.js';
export { default as getPdfStoragePath } from './getPdfStoragePath.js';
export { default as isWhitelistedContentType } from './isWhitelistedContentType.js';
export { default as retryFunction } from './retryFunction.js';
export { default as randomThreeDigitNumberString } from './randomThreeDigitNumberString.js';
export { areLinksEqual, isFollowStrategy } from './linkStrategy.js';
export { getUserDataFilePath, getUserDataTxt, writeToUserDataTxt } from './userData.js';
Expand Down
16 changes: 16 additions & 0 deletions src/utils/retryFunction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const retryFunction = async <T>(func: () => Promise<T>, maxAttempt: number): Promise<T> => {
let attemptCount = 0;
while (attemptCount < maxAttempt) {
attemptCount += 1;
try {
// eslint-disable-next-line no-await-in-loop
const result = await func();
return result;
} catch (error) {
// do nothing, just retry
}
}
throw new Error('Maximum number of attempts reached');
};

export default retryFunction;