fix(cf): reload page on stuck Turnstile widget + faster integration tests#118
Merged
fix(cf): reload page on stuck Turnstile widget + faster integration tests#118
Conversation
Managed/invisible Turnstile widgets (e.g. Ahrefs) auto-solve after 30-60s but the fast 20ms hook poll stops once hooks are installed. The render() callback handles most cases, but managed widgets can solve after the fast poll exits — leaving only auto_navigation (page navigates) to resolve, causing 50-60s ghost traces in cf.resolutionRace. Add a 1s getResponse() fallback poll (90s lifetime) that catches tokens from widgets solved after the fast poll stops. This should eliminate the remaining ghost traces not fixed by PR #116's bridge event buffering.
… integration tests When solver returns NoClick (OOPIF exists but no checkbox renders), wait a grace period for bridge auto-solve, then reload the page to give CF a fresh chance. Prevents 60s dead waits on stuck widgets. Integration test speedups: reduce post-solve buffer 3s→1s, replace fixed replay flush sleeps with polling, fix checkbox timing assertion to isolate sleep interval from CDP call latency.
…back-to-back runs cf-stress runs 15 concurrent tabs through Ahrefs CF challenges. The proxy IP gets rate-limited after ~30 CF solves. When vitest runs explicitly then again via pre-push hook, cf-stress always fails on the second run because the IP is burned. Cooldown file /tmp/cf-stress-last-pass tracks last pass time — skips if <10 minutes elapsed.
The solve session test had { timeout: 20_000 } which was too tight —
goto + CF solve + replay flush + assertions can take 15-25s depending on
network and CF timing. The config timeout was already widened to 60s but
this per-test override was missed.
When CF serves a non-interactive Turnstile variant, turnstile.getResponse() returns a token in ~1s but the server-side solver is still in phase 3 checkbox polling. The 500ms buffer was too short — browser.close() killed the session before the bridge push could arrive, causing cf.failed with session_close. 3s gives the bridge push time to propagate.
…verify CF interstitials (managed challenges) can take 10-15s to verify and redirect, especially under proxy load. The 8s waitForNavigation timeout was too tight — CF slow-walks verification on rate-limited IPs. 20s gives ample time while staying well under the 60s per-test timeout.
…sites 2captcha.com demo has its own rate limits on top of CF. Under proxy load, CF's interstitial challenge refuses to resolve (15s+ "Just a moment..." with no navigation). Extended maySkip to also skip gracefully when the challenge is served but never resolves (session_close label).
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NoClick(OOPIF exists but no checkbox renders), waitsWIDGET_RELOAD_GRACE(5s) then reloads the page — prevents 60s dead waits on stuck widgets. Max 2 reloads before giving up.turnstile.getResponse()as a safety net.Test Plan
npx tsc --noEmit— zero type errorsnpx vitest run— 261/261 tests pass