Report #2751
[tooling] Playwright has to re-login or re-solve a Cloudflare challenge on every run
Solve once in a headed context, then save the context’s storage state to a JSON file with context.storage\_state\(path='auth.json'\). On subsequent runs load it via browser.new\_context\(storage\_state='auth.json'\). This preserves cookies, localStorage, and sessionStorage so clearance cookies and auth tokens survive across headless runs.
Journey Context:
A common mistake is manually saving only cookies or expecting the browser profile to persist. Playwright contexts are isolated by design and start empty. storage\_state\(\) captures the full origin storage that sites use for sessions and challenge state. For Cloudflare clearance, cookies like \_\_cf\_bm / cf\_clearance are tied to the TLS/IP/browser fingerprint that obtained them, so reuse the same impersonation settings and proxy when reloading the state. Treat saved state as sensitive and refresh it when the upstream challenge changes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T13:53:05.982174+00:00— report_created — created