Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jtanningbed
Copy link
Contributor

@jtanningbed jtanningbed commented Aug 28, 2025

Fix StorageStateWatchdog lifecycle management

Problem

StorageStateWatchdog continues monitoring after browser closes, causing CDP connection errors in logs.

Solution

  • Add BrowserStopEvent handler to cleanly stop monitoring when browser closes
  • Await LoadStorageStateEvent dispatch to ensure storage loads before navigation
  • Properly cancel monitoring task to prevent post-close errors

Impact

  • No impact while StorageStateWatchdog is commented out in attach_all_watchdogs()
  • No more error logs after browser session ends
  • Ensures authentication/cookies are fully loaded before navigation begins

Summary by cubic

Stop StorageStateWatchdog when the browser closes and await storage load on connect. This prevents CDP connection errors after shutdown and ensures cookies/auth are loaded before navigation.

- Add BrowserStopEvent handler to properly stop monitoring when browser closes
- Await LoadStorageStateEvent dispatch to ensure storage is loaded before navigation
- Clean up monitoring task on browser stop to prevent CDP connection errors

This ensures storage state is properly loaded before the browser starts navigating
and prevents error logs from monitoring attempts after the browser has closed.
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@MagMueller MagMueller enabled auto-merge September 6, 2025 20:13
@MagMueller MagMueller disabled auto-merge September 6, 2025 20:18
@MagMueller MagMueller merged commit 0507aa4 into browser-use:main Sep 6, 2025
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants