Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
fix(browser): preserve EventBus_ name prefix on ResilientEventBus
Saurav Panda9c1db02dd383
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex 15867e8e9..fb0209d1b 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -118,6 +118,14 @@ class ResilientEventBus(EventBus):``dispatch()`` still restarts the bus as usual."""+ def __init__(self, name: str | None = None, **kwargs: Any) -> None:+ # bubus derives the default bus name from the class name, which would make session+ # buses ``ResilientEventBus_*`` instead of ``EventBus_*``. Keep the original prefix so+ # bus names stay stable for logging/identification (matches EventBus's own scheme).+ if name is None:+ name = f'EventBus_{uuid7str()[-8:]}'+ super().__init__(name=name, **kwargs)+async def step(self,event: 'BaseEvent[Any] | None' = None,diff --git a/tests/ci/test_event_bus_resilience.py b/tests/ci/test_event_bus_resilience.pyindex 29f85b8d5..17445ea3a 100644--- a/tests/ci/test_event_bus_resilience.py+++ b/tests/ci/test_event_bus_resilience.py@@ -34,6 +34,13 @@ def test_browser_session_uses_resilient_event_bus():assert isinstance(session.event_bus, ResilientEventBus)+def test_resilient_event_bus_keeps_event_bus_name_prefix():+ """The subclass must keep the ``EventBus_`` default name (not ``ResilientEventBus_``)."""+ assert ResilientEventBus().name.startswith('EventBus_')+ # Explicit names are still honored.+ assert ResilientEventBus(name='EventBus_custom').name == 'EventBus_custom'++async def test_step_on_torn_down_bus_is_noop_not_assertion():"""Stepping a stopped+nulled bus returns None instead of raising AssertionError."""bus = ResilientEventBus(name='ResilientWarmResumeStep')