mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
fix(runtime): clean up sessions on disconnect (#17)
* fix(runtime): clean up sessions on disconnect * chore(ci): match Biome 2.4 formatting * ci: retry stalled Rust job * test: bind daemon ports without probe races
This commit is contained in:
1 parent
c75f97119d
commit
1371c92721
8 files changed
+261
-24
No files matched your search
@@ -286,6 +286,17 @@ async fn drive_connection(
|
||||
// socket's cleanup path uses `remove_if_generation_matches` to
|
||||
// avoid clobbering the newer entry (review M4/M5 round 2 #1).
|
||||
let browser_id = BrowserId(params.instance_id.clone());
|
||||
// A fresh socket represents a fresh extension control plane. The
|
||||
// extension tears down its local sessions before reconnecting, so any
|
||||
// daemon-side sessions left under the same instance id are stale. Purge
|
||||
// them before replacing the browser registration; otherwise an old WS
|
||||
// cleanup racing with this handshake can preserve rows that no longer
|
||||
// have an Agent Window on the extension side.
|
||||
for session in state.sessions.purge_browser(&browser_id) {
|
||||
state.tool_queues.remove(&session.id);
|
||||
state.session_interrupts.drop_session(&session.id);
|
||||
debug!(session = %session.id, "purged stale session before browser reconnect");
|
||||
}
|
||||
let (tx, mut rx) = mpsc::unbounded_channel::<Frame>();
|
||||
let generation = super::browsers::next_browser_generation();
|
||||
let connected_at_ms = std::time::SystemTime::now()
|
||||
|
||||
Reference in new issue
Block a user