fix: improve CF challenge detection and add timeout in cf-fetch
CI / check (push) Successful in 24s
CI / release (push) Skipped
CI / deploy (push) Successful in 1m1s

This commit is contained in:
openhands committed 2026-08-04 18:17:20 +02:00
1 parent 847febbe64
commit c565351c2f
1 file changed
+9 -4
+9 -4
View File
@@ -49,14 +49,19 @@ export async function fetchWithCfBypass(
status === 403; status === 403;
if (isCfChallenge) { if (isCfChallenge) {
try {
await page.waitForFunction( await page.waitForFunction(
() => () =>
!document.body.innerHTML.includes("Attention Required") && document.body.innerHTML.includes("cf-captcha") ||
!document.body.innerHTML.includes("Checking your browser") && document.body.innerHTML.includes("challenge-platform"),
!document.body.innerHTML.includes("Just a moment"), { timeout: 5000 },
{ timeout: 10000 },
); );
} catch {
// CF challenge might have been solved already
} }
}
await new Promise((resolve) => setTimeout(resolve, 2000));
const finalBody = await page.content(); const finalBody = await page.content();
return finalBody; return finalBody;