Skip to content
Merged
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
10 changes: 0 additions & 10 deletions src/_internalUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,12 @@ export type Brand<T, Brand extends string> = T & {
readonly [B in Brand as `__${B}_brand`]: never;
};

const FLAKINESS_DBG = !!process.env.FLAKINESS_DBG;
export function errorText(error: Error) {
return FLAKINESS_DBG ? error.stack : error.message;
}

export async function retryWithBackoff<T>(job: () => Promise<T>, backoff: number[] = []): Promise<T> {
for (const timeout of backoff) {
try {
return await job();
} catch (e: any) {
if (e instanceof AggregateError)
console.error(`[flakiness.io err]`, errorText(e.errors[0]));
else if (e instanceof Error)
console.error(`[flakiness.io err]`, errorText(e));
else
console.error(`[flakiness.io err]`, e);
await new Promise(x => setTimeout(x, timeout));
}
}
Expand Down
Loading