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
+12 -7
+12 -7
View File
@@ -49,15 +49,20 @@ export async function fetchWithCfBypass(
status === 403;
if (isCfChallenge) {
await page.waitForFunction(
() =>
!document.body.innerHTML.includes("Attention Required") &&
!document.body.innerHTML.includes("Checking your browser") &&
!document.body.innerHTML.includes("Just a moment"),
{ timeout: 10000 },
);
try {
await page.waitForFunction(
() =>
document.body.innerHTML.includes("cf-captcha") ||
document.body.innerHTML.includes("challenge-platform"),
{ timeout: 5000 },
);
} catch {
// CF challenge might have been solved already
}
}
await new Promise((resolve) => setTimeout(resolve, 2000));
const finalBody = await page.content();
return finalBody;
} finally {