mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-03 02:11:48 +00:00
fix(browser_supervisor): verify thread and loop health before returning cached supervisor
_SupervisorRegistry.get_or_start() returned an existing supervisor whenever the cdp_url matched, without checking if the supervisor's thread or event loop was still alive. A crashed supervisor would be silently reused, causing missed dialog/frame updates. Now checks both _thread.is_alive() and _loop.is_running() before returning the cached instance. An unhealthy supervisor is torn down and recreated, matching the existing URL-changed code path.
This commit is contained in:
parent
ec4cb16a29
commit
73a6b80317
1 changed files with 6 additions and 2 deletions
|
|
@ -1304,8 +1304,12 @@ class _SupervisorRegistry:
|
|||
existing = self._by_task.get(task_id)
|
||||
if existing is not None:
|
||||
if existing.cdp_url == cdp_url:
|
||||
return existing
|
||||
# URL changed — tear down old, fall through to re-create.
|
||||
thread_ok = existing._thread is not None and existing._thread.is_alive()
|
||||
loop_ok = existing._loop is not None and existing._loop.is_running()
|
||||
if thread_ok and loop_ok:
|
||||
return existing
|
||||
# Unhealthy — tear down and recreate.
|
||||
# URL changed or unhealthy — tear down, fall through to re-create.
|
||||
self._by_task.pop(task_id, None)
|
||||
if existing is not None:
|
||||
existing.stop()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue