Skip to content

Commit

Permalink
Fix the test_stream function running after the stream is closed (#3396)
Browse files Browse the repository at this point in the history
  • Loading branch information
ealmloff authored Jan 8, 2025
1 parent 5815e05 commit 5ea0867
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/fullstack-streaming/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ pub async fn test_stream() -> Result<TextStream, ServerFnError> {
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;
}
}
});

Expand Down

0 comments on commit 5ea0867

Please sign in to comment.