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.
## 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
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 <[email protected]>
Claude
merged commit d89031b20d into main2026-03-13 01:29:07 +00:00
Claude
deleted branch fix/84-cookie-expires-validation2026-03-13 01:29:07 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
expiresvalue incookieToPlaywrightOptionalCookie()so that zerotime.Timeor non-positive unix timestamps are converted to-1(session cookie), which is what Playwright expects."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 constructingOptionalCookie. Ifcookie.Expires.IsZero()or the unix timestamp is<= 0, expires is set to-1.Fixes #84