-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove exp show and plots diff retry when git repo has no commits
- Loading branch information
1 parent
4775826
commit 36571f5
Showing
8 changed files
with
109 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
import { delay } from '../util/time' | ||
import { Logger } from '../common/logger' | ||
|
||
export const retry = async <T>( | ||
getNewPromise: () => Promise<T>, | ||
const isNonRetryError = ( | ||
errorMessage: string, | ||
nonRetryErrors: string[] | ||
): boolean => { | ||
for (const partialErrorMessage of nonRetryErrors) { | ||
if (errorMessage.includes(partialErrorMessage)) { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
export const retry = async ( | ||
getNewPromise: () => Promise<string>, | ||
args: string, | ||
nonRetryErrors: string[], | ||
waitBeforeRetry = 500 | ||
): Promise<T> => { | ||
): Promise<string> => { | ||
try { | ||
return await getNewPromise() | ||
} catch (error: unknown) { | ||
const errorMessage = (error as Error).message | ||
Logger.error(`${args} failed with ${errorMessage} retrying...`) | ||
|
||
if (isNonRetryError(errorMessage, nonRetryErrors)) { | ||
return '' | ||
} | ||
|
||
await delay(waitBeforeRetry) | ||
return retry(getNewPromise, args, waitBeforeRetry * 2) | ||
return retry(getNewPromise, args, nonRetryErrors, waitBeforeRetry * 2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters