diff --git a/backend/clients/myTischtennisClient.js b/backend/clients/myTischtennisClient.js index 509d51d5..96d75421 100644 --- a/backend/clients/myTischtennisClient.js +++ b/backend/clients/myTischtennisClient.js @@ -547,7 +547,9 @@ class MyTischtennisClient { // Wait for auth cookie after submit (polling avoids timing races). let authCookieObj = null; - const maxAttempts = 80; + let detectedSubmitError = null; + const pollIntervalMs = 500; + const maxAttempts = 40; // ~20s max wait after submit for (let attempt = 0; attempt < maxAttempts; attempt++) { const cookies = await context.cookies(); authCookieObj = cookies.find((c) => c.name === 'sb-10-auth-token') @@ -557,7 +559,29 @@ class MyTischtennisClient { console.log('[myTischtennisClient.playwright] Auth cookie detected:', authCookieObj.name); break; } - await page.waitForTimeout(500); + + // Probe page text periodically to fail fast instead of waiting full timeout. + if (attempt % 4 === 0) { + try { + const textContent = await page.locator('body').innerText({ timeout: 600 }); + if (textContent?.includes('Captcha-Bestätigung fehlgeschlagen')) { + detectedSubmitError = 'Captcha-Bestätigung fehlgeschlagen'; + break; + } + if (textContent?.includes('Captcha-Bestätigung ist erforderlich')) { + detectedSubmitError = 'Captcha-Bestätigung ist erforderlich'; + break; + } + if (textContent?.includes('Ungültige E-Mail oder Passwort')) { + detectedSubmitError = 'Ungültige E-Mail oder Passwort'; + break; + } + } catch (_readBodyErr) { + // ignore text read errors during polling + } + } + + await page.waitForTimeout(pollIntervalMs); } if (!authCookieObj || !authCookieObj.value) { let errorText = null; @@ -572,6 +596,9 @@ class MyTischtennisClient { } catch (_e) { // ignore text read errors } + if (!errorText && detectedSubmitError) { + errorText = detectedSubmitError; + } return { success: false, error: errorText