Skip to content

Commit

Permalink
wip: retry tmp dir removal
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori committed Nov 15, 2022
1 parent df1bd61 commit a6aeafb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/remix-dev/__tests__/utils/withApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ import os from "os";
import path from "path";
import fse from "fs-extra";

const retry = async (
callback: () => Promise<void>,
times: number,
delayMs: number = 0
) => {
try {
await callback();
} catch (error) {
if (times === 0) throw error;
setTimeout(() => retry(callback, times - 1), delayMs);
}
};

export default async <Result>(
fixture: string,
callback: (projectDir: string) => Promise<Result>
Expand All @@ -19,6 +32,6 @@ export default async <Result>(
let result = await callback(projectDir);
return result;
} finally {
await fse.remove(TEMP_DIR);
retry(async () => await fse.remove(TEMP_DIR), 3, 200);
}
};

0 comments on commit a6aeafb

Please sign in to comment.