-
Notifications
You must be signed in to change notification settings - Fork 673
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! test: add C3 integration test to Wrangler e2e tests
- Loading branch information
1 parent
5bfd020
commit c6f35fb
Showing
7 changed files
with
104 additions
and
50 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
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,20 +1,22 @@ | ||
import { setTimeout } from "node:timers/promises"; | ||
|
||
export async function retry<T>( | ||
originalState: T, | ||
retryIf: (currentState: T) => boolean, | ||
action: () => Promise<T>, | ||
n = 20 | ||
n = 30 | ||
): Promise<T> { | ||
const states: T[] = []; | ||
while (n >= 0) { | ||
try { | ||
const currentState = await action(); | ||
if (currentState !== originalState) { | ||
if (!retryIf(currentState)) { | ||
return currentState; | ||
} | ||
} catch (e) { | ||
await setTimeout(2_000); | ||
n--; | ||
} | ||
states.push(currentState); | ||
} catch {} | ||
await setTimeout(2_000); | ||
n--; | ||
} | ||
console.error(states); | ||
throw new Error("Timed out waiting for state to change"); | ||
} |