From 5ea0867a340098b3cdebe3d076200f1f0f847364 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 8 Jan 2025 17:00:05 -0600 Subject: [PATCH] Fix the test_stream function running after the stream is closed (#3396) --- examples/fullstack-streaming/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/fullstack-streaming/src/main.rs b/examples/fullstack-streaming/src/main.rs index ac3bb7e9a..041ff2228 100644 --- a/examples/fullstack-streaming/src/main.rs +++ b/examples/fullstack-streaming/src/main.rs @@ -30,7 +30,10 @@ pub async fn test_stream() -> Result { loop { tokio::time::sleep(tokio::time::Duration::from_millis(500)).await; dioxus::logger::tracing::info!("Sending new chunk!"); - let _ = tx.unbounded_send(Ok("Hello, world!".to_string())); + if tx.unbounded_send(Ok("Hello, world!".to_string())).is_err() { + // If the channel is closed, stop sending chunks + break; + } } });