From 2274dd4eeb6189876144d9a5e76fb27b001e30d0 Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Mon, 30 Mar 2026 17:08:48 +0100 Subject: [PATCH] Fix cross-runtime panic in mix-fetch when timed-out requests receive late error injection - Add early return in reject() when request is already gone from Rust map - Replace panic with log + return in SendError and InjectData --- wasm/mix-fetch/go-mix-conn/internal/state/state.go | 6 ++++-- wasm/mix-fetch/src/active_requests.rs | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/wasm/mix-fetch/go-mix-conn/internal/state/state.go b/wasm/mix-fetch/go-mix-conn/internal/state/state.go index ca05ff5812..4db50a1c49 100644 --- a/wasm/mix-fetch/go-mix-conn/internal/state/state.go +++ b/wasm/mix-fetch/go-mix-conn/internal/state/state.go @@ -92,7 +92,8 @@ func (ar *CurrentActiveRequests) InjectData(id types.RequestId, data []byte) { defer ar.Unlock() _, exists := ar.Requests[id] if !exists { - panic("attempted to write to connection that doesn't exist") + log.Error("attempted to inject data for connection %d that no longer exists — likely already cleaned up", id) + return } ar.Requests[id].injector.ServerData <- data } @@ -115,7 +116,8 @@ func (ar *CurrentActiveRequests) SendError(id types.RequestId, err error) { defer ar.Unlock() _, exists := ar.Requests[id] if !exists { - panic("attempted to inject error data to connection that doesn't exist") + log.Error("attempted to inject error for connection %d that no longer exists — likely already cleaned up", id) + return } ar.Requests[id].injector.RemoteError <- err } diff --git a/wasm/mix-fetch/src/active_requests.rs b/wasm/mix-fetch/src/active_requests.rs index 72fe6ac9d9..e0f61daa7f 100644 --- a/wasm/mix-fetch/src/active_requests.rs +++ b/wasm/mix-fetch/src/active_requests.rs @@ -69,7 +69,8 @@ impl ActiveRequests { let mut guard = self.inner.lock().await; let old = guard.remove(&id); if old.is_none() { - console_error!("attempted to reject request {id}, but it seems to have never existed?") + console_error!("attempted to reject request {id}, but it no longer exists — likely already cleaned up by Go timeout"); + return; } goWasmInjectConnError(id.to_string(), err.to_string())