fix: sanitize cookie expires for Playwright compatibility #85

Merged
Claude merged 1 commits from fix/84-cookie-expires-validation into main 2026-03-13 01:29:07 +00:00
Collaborator

Summary

  • Sanitize the expires value in cookieToPlaywrightOptionalCookie() so that zero time.Time or non-positive unix timestamps are converted to -1 (session cookie), which is what Playwright expects.
  • This fixes the "Cookie should have a valid expires" warning that fires on every browser init when loading cookies from the jar.

Changes

  • playwright.go: Added expires validation before constructing OptionalCookie. If cookie.Expires.IsZero() or the unix timestamp is <= 0, expires is set to -1.

Fixes #84

## Summary - Sanitize the `expires` value in `cookieToPlaywrightOptionalCookie()` so that zero `time.Time` or non-positive unix timestamps are converted to `-1` (session cookie), which is what Playwright expects. - This fixes the `"Cookie should have a valid expires"` warning that fires on every browser init when loading cookies from the jar. ## Changes - `playwright.go`: Added expires validation before constructing `OptionalCookie`. If `cookie.Expires.IsZero()` or the unix timestamp is `<= 0`, expires is set to `-1`. Fixes #84
Claude added 1 commit 2026-03-13 01:28:58 +00:00
fix: sanitize cookie expires for Playwright compatibility
All checks were successful
CI / build (pull_request) Successful in 1m51s
CI / vet (pull_request) Successful in 2m38s
CI / test (pull_request) Successful in 2m59s
84e811572b
Playwright requires cookie expires to be either -1 (session cookie) or
a positive unix timestamp. When a cookie has no expiry (zero time.Time),
.Unix() returns -62135596800 which Playwright rejects. Cookies with
non-positive timestamps (e.g. Cloudflare's __cf_bm) also fail.

Now treats zero time or non-positive unix timestamps as session cookies
by setting expires to -1.

Fixes #84

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude merged commit d89031b20d into main 2026-03-13 01:29:07 +00:00
Claude deleted branch fix/84-cookie-expires-validation 2026-03-13 01:29:07 +00:00
Sign in to join this conversation.