Fix the test_stream function running after the stream is closed (#3396)

This commit is contained in:
Evan Almloff authored and GitHub committed 2025-01-08 15:00:05 -08:00
1 parent 5815e05014
commit 5ea0867a34
1 file changed
+4 -1
+4 -1
View File
@@ -30,7 +30,10 @@ pub async fn test_stream() -> Result<TextStream, ServerFnError> {
loop { loop {
tokio::time::sleep(tokio::time::Duration::from_millis(500)).await; tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
dioxus::logger::tracing::info!("Sending new chunk!"); 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;
}
} }
}); });