Log WS state transitions in production

The bridge already turns WsState changes into stats pulses for the UI
but never logged the transition itself, so an INFO-only log stream had
no record of reconnects. Track the previous state in the watcher and
emit `info!` on each genuine transition (skipping duplicate sets from
the same state — `publish()` is called a few times redundantly during
the connect handshake). Picks up [[sdk]] commit
1036d6f2e5 (SDK heartbeat + idle timeout) via the submodule bump.
This commit is contained in:
Anthony
2026-05-28 19:17:36 +02:00
parent d07b0bd911
commit 9b7042d6a7
2 changed files with 13 additions and 2 deletions
+12 -1
View File
@@ -290,13 +290,24 @@ impl BridgeHandle {
let mut store_watch = store.subscribe();
let mut ws_watch = bus_client.state();
let mut shutdown_watch = shutdown_sync_rx.clone();
// Track the previous WS state so we only log on transitions,
// not on every internal `publish()` (some calls re-set the same
// state).
let mut last_ws_state = *ws_watch.borrow();
tokio::spawn(async move {
// Initial pulse so a subscriber sees the freshly-started state.
let _ = stats_dirty.send(());
loop {
tokio::select! {
_ = store_watch.changed() => { let _ = stats_dirty.send(()); }
_ = ws_watch.changed() => { let _ = stats_dirty.send(()); }
_ = ws_watch.changed() => {
let now = *ws_watch.borrow();
if now != last_ws_state {
log::info!("ws state: {:?} → {:?}", last_ws_state, now);
last_ws_state = now;
}
let _ = stats_dirty.send(());
}
_ = shutdown_watch.changed() => return,
}
}