Skip to content

Commit

Permalink
refactor: retry decorator for polling
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Aug 6, 2024
1 parent c10653b commit d084ea5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/util/fileLocking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,17 @@ export const lockInitSync = (filePath: string): LockInitSyncResponse => {
* @param filePath file path to check
*/
export const pollUntilUnlock = async (filePath: string): Promise<void> => {
await retryDecorator(check, {
timeout: Duration.minutes(1).milliseconds,
delay: 10,
until: (locked) => locked === false,
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
retryIf: () => false,
})(filePath, lockRetryOptions);
try {
await retryDecorator(check, {
timeout: Duration.minutes(1).milliseconds,
delay: 10,
until: (locked) => locked === false,
// don't retry errors (typically enoent or access on the lockfile, therefore not locked)
retryIf: () => false,
})(filePath, lockRetryOptions);
} catch (e) {
// intentionally swallow the error, same reason as above
}
};

export const pollUntilUnlockSync = (filePath: string): void => {
Expand Down

0 comments on commit d084ea5

Please sign in to comment.