Fix the test_stream function running after the stream is closed (#3396)
This commit is contained in:
1 parent
5815e05014
commit
5ea0867a34
1 file changed
+4
-1
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user