fix: check Cookies() error and use context-aware sleep
- playwright.go: check error from page.Context().Cookies() before iterating over results, preventing silent failures - archive.go: replace time.Sleep(5s) with context-aware select using time.After, allowing the operation to be cancelled promptly Closes #7, #18 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -138,6 +138,9 @@ func NewBrowser(ctx context.Context, opts ...BrowserOptions) (Browser, error) {
|
||||
func (b playWrightBrowser) updateCookies(_ context.Context, page playwright.Page) error {
|
||||
if b.cookieJar != nil {
|
||||
cookies, err := page.Context().Cookies(page.URL())
|
||||
if err != nil {
|
||||
return fmt.Errorf("error getting cookies from browser: %w", err)
|
||||
}
|
||||
|
||||
for _, cookie := range cookies {
|
||||
// TODO: add support for deleting cookies from the jar which are deleted in the browser
|
||||
|
||||
Reference in New Issue
Block a user