From 37719a3fac3b6f33fdc028394bcac23f2a265c35 Mon Sep 17 00:00:00 2001 From: ospab Date: Sat, 30 May 2026 21:55:33 +0300 Subject: [PATCH] fix(client): flush stale proxy_rx messages on background reconnect to prevent UDP burst drops on mobile networks --- ostp-client/src/bridge.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ostp-client/src/bridge.rs b/ostp-client/src/bridge.rs index 5d83ca0..83f18ec 100644 --- a/ostp-client/src/bridge.rs +++ b/ostp-client/src/bridge.rs @@ -511,6 +511,19 @@ impl Bridge { // Connect/UdpAssociate over the new session, avoiding a 5-minute blackhole. stream_map.clear(); 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 { let _ = tx.send(UiEvent::Log("Background reconnect failed. Will retry on next tick...".into())).await; }