From b4cbc4f33bf0d5377476efa233062a8a6cf69465 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Thu, 21 Aug 2025 03:25:46 +0000 Subject: [PATCH] fix(connlib): exit phoenix-channel event-loop on error (#10229) We cannot poll the `PhoenixChannel` after it has returned an error, otherwise it will panic. Therefore, we exit the event-loop then. The outer event-loop also exits as soon as it receives an error from this channel so this is fine. `PhoenixChannel` only returns an error when it has irrecoverably disconnected, e.g. after the retries have been exhausted or we hit a 4xx error on the WebSocket connection. --------- Signed-off-by: Thomas Eizinger Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- rust/client-shared/src/eventloop.rs | 7 +++---- rust/gateway/src/eventloop.rs | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/rust/client-shared/src/eventloop.rs b/rust/client-shared/src/eventloop.rs index be3eb0a97..33fb42002 100644 --- a/rust/client-shared/src/eventloop.rs +++ b/rust/client-shared/src/eventloop.rs @@ -479,10 +479,9 @@ async fn phoenix_channel_event_loop( "Hiccup in portal connection: {error:#}" ), Either::Left((Err(e), _)) => { - if event_tx.send(PortalEvent::Error(e)).await.is_err() { - tracing::debug!("Event channel closed: exiting phoenix-channel event-loop"); - break; - } + let _ = event_tx.send(PortalEvent::Error(e)).await; // We don't care about the result because we are exiting anyway. + + break; } Either::Right((Some(PortalCommand::Send(msg)), _)) => { portal.send(PHOENIX_TOPIC, msg); diff --git a/rust/gateway/src/eventloop.rs b/rust/gateway/src/eventloop.rs index 59f0599db..93ea7dc2a 100644 --- a/rust/gateway/src/eventloop.rs +++ b/rust/gateway/src/eventloop.rs @@ -632,10 +632,9 @@ async fn phoenix_channel_event_loop( "Hiccup in portal connection: {error:#}" ), Either::Left((Err(e), _)) => { - if event_tx.send(Err(e)).await.is_err() { - tracing::debug!("Event channel closed: exiting phoenix-channel event-loop"); - break; - } + let _ = event_tx.send(Err(e)).await; // We don't care about the result because we are exiting anyway. + + break; } Either::Right((Some(PortalCommand::Send(msg)), _)) => { portal.send(PHOENIX_TOPIC, msg);