Skip to content

refactor(daemon): name stale session recovery boundary#353

Open
honor2030 wants to merge 1 commit into
browser-use:mainfrom
honor2030:refactor/session-recovery-boundary
Open

refactor(daemon): name stale session recovery boundary#353
honor2030 wants to merge 1 commit into
browser-use:mainfrom
honor2030:refactor/session-recovery-boundary

Conversation

@honor2030
Copy link
Copy Markdown

@honor2030 honor2030 commented May 13, 2026

Summary

  • Extract the daemon's stale current-session retry check into a named recovery boundary.
  • Add tests that make the safe recovery contract explicit: only calls using the daemon's current default session should re-attach and retry.
  • Cover the existing re-attach + retry behavior as the first small implementation slice for the lifecycle design proposal.

Refs #352

Test Plan

  • RED: uv run --with pytest --with pillow python -m pytest tests/unit/test_daemon.py::test_recoverable_current_session_error_requires_current_default_session -q failed before the implementation with AttributeError: module 'browser_harness.daemon' has no attribute '_is_recoverable_current_session_error'.
  • GREEN: uv run --with pytest --with pillow python -m pytest tests/unit/test_daemon.py -q11 passed.
  • GREEN: uv run --with pytest --with pillow python -m pytest tests -q98 passed.
  • GREEN: uv run python -m compileall -q src tests.
  • GREEN: uv pip check --python .venv/bin/python → all installed packages compatible.
  • GREEN: uv run --with ruff python -m ruff check --select B tests/unit/test_daemon.py → all checks passed.

Summary by cubic

Named a clear recovery boundary for stale current-session errors in the daemon and added tests to lock down the behavior. Only calls using the daemon’s current default session will auto re-attach and retry, progressing #352.

  • Refactors
    • Extracted _is_recoverable_current_session_error with STALE_SESSION_MARKERS.
    • Auto re-attach + retry only when sid matches the current default session; browser-level and explicit session calls surface the original error.
    • Added unit tests to define the contract and cover the re-attach + retry path.

Written for commit d0f6578. Summary will update on new commits.

Copy link
Copy Markdown
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 2 files

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.

1 participant