refactor: Max pogingen account maken

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Tibo De Peuter 2025-04-14 09:17:34 +02:00
parent a74e786da2
commit 47bbacc2ad
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2

View file

@ -42,7 +42,9 @@ async function acquireAccount(id: number, browser: Browser): Promise<Account> {
await page.getByRole("link", { name: "Register" }).click();
}
while (failed) {
const MAX_RETRIES = 5;
let retries = 0;
while (failed && retries < MAX_RETRIES) {
// Retry with a different username, based on Unix timestamp.
account.username = `worker${id}-${Date.now()}`;
@ -57,6 +59,7 @@ async function acquireAccount(id: number, browser: Browser): Promise<Account> {
await page.waitForURL(/localhost/);
failed = await page.getByText("Username already exists.").isVisible();
retries += failed ? 1 : 0;
}
await page.waitForURL(/localhost/);