fix(client): flush stale proxy_rx messages on background reconnect to prevent UDP burst drops on mobile networks

This commit is contained in:
ospab 2026-05-30 21:55:33 +03:00
parent e90bfc7510
commit 37719a3fac
1 changed files with 13 additions and 0 deletions

View File

@ -511,6 +511,19 @@ impl Bridge {
// Connect/UdpAssociate over the new session, avoiding a 5-minute blackhole. // Connect/UdpAssociate over the new session, avoiding a 5-minute blackhole.
stream_map.clear(); stream_map.clear();
self.reset_proxy_streams(&tx, &proxy_tx, "background reconnect"); self.reset_proxy_streams(&tx, &proxy_tx, "background reconnect");
// FIX: Flush all stale proxy messages accumulated during the stall/reconnect
// This prevents a massive post-reconnect UDP burst that causes mobile carriers to drop all packets
let mut flushed = 0;
while let Ok(stale) = proxy_rx.try_recv() {
if let ProxyEvent::NewStream { stream_id, .. } = stale {
let _ = proxy_tx.send((stream_id, ProxyToClientMsg::Error("connection reset".into())));
}
flushed += 1;
}
if flushed > 0 {
let _ = tx.send(UiEvent::Log(format!("Flushed {} stale proxy messages to prevent UDP burst", flushed))).await;
}
} else { } else {
let _ = tx.send(UiEvent::Log("Background reconnect failed. Will retry on next tick...".into())).await; let _ = tx.send(UiEvent::Log("Background reconnect failed. Will retry on next tick...".into())).await;
} }