cookieToPlaywrightOptionalCookie passes invalid expires values to Playwright #84
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
cookieToPlaywrightOptionalCookie()inplaywright.go:130unconditionally converts the cookie'sExpiresfield to a unix timestamp:Playwright's
AddCookies()requires theexpiresfield to be either:-1— session cookie (no expiry)When a cookie has no expiry set (session cookie),
cookie.Expiresis the zerotime.Time, and.Unix()returns-62135596800— a large negative number that Playwright rejects.This also affects cookies like Cloudflare's
__cf_bmwhich may have an expires value that results in0or another non-positive timestamp.Observed Error
This warning fires on every browser initialization when cookies are loaded from the jar, which happens repeatedly during newsfeed polling.
Suggested Fix
In
cookieToPlaywrightOptionalCookie(), sanitize the expires value:Location
playwright.go:124-138—cookieToPlaywrightOptionalCookie()browser_init.go:155-159— where the warning is loggedStarting work on this. Plan: sanitize the
expiresvalue incookieToPlaywrightOptionalCookie()so that zero/non-positive timestamps become-1(session cookie), matching Playwright's requirements.Fixed in PR #85 (merged). The
cookieToPlaywrightOptionalCookie()function now setsexpires = -1whencookie.Expires.IsZero()or the unix timestamp is non-positive, matching Playwright's requirements.