Wait for the suspense boundary above the router to resolve before sending the first streaming chunk (#3891)

* Change the suspense streaming context after suspense is resolved in the router

* Wait for the suspense context before streaming the first chunk in ssr

* forward more response parts

* warn

* extract the hydration format into a crate

* Fix hydration when no data is sent

* forward web and server features

* Fix suspense that starts on the client

* fix use_server_future on the client

* Add documentation for fullstack hooks and protocol

* downgrade rust edition

* fix clippy

* fix tests

* fix clippy

* Fix pure web compile

* undo changes to the fullstack router example

* fix formatting
This commit is contained in:
Evan Almloff authored and GitHub committed 2025-04-08 16:01:21 -05:00
1 parent 4f74ef81d1
commit 84221f55a0
45 files changed
+988 -533

No files matched your search

+2 -14
View File
@@ -202,8 +202,7 @@ async fn handle_server_fns_inner(
}
// apply the response parts from the server context to the response
let mut res_options = server_context.response_parts_mut();
res.headers_mut().extend(res_options.headers.drain());
server_context.send_response(&mut res);
Ok(res)
} else {
@@ -237,16 +236,6 @@ pub(crate) fn add_server_context(
}
}
fn apply_request_parts_to_response<B>(
headers: hyper::header::HeaderMap,
response: &mut axum::response::Response<B>,
) {
let mut_headers = response.headers_mut();
for (key, value) in headers.iter() {
mut_headers.insert(key, value.clone());
}
}
/// State used by [`render_handler`] to render a dioxus component with axum
#[derive(Clone)]
pub struct RenderHandleState {
@@ -367,8 +356,7 @@ pub async fn render_handler(
Ok((freshness, rx)) => {
let mut response = axum::response::Html::from(Body::from_stream(rx)).into_response();
freshness.write(response.headers_mut());
let headers = server_context.response_parts().headers.clone();
apply_request_parts_to_response(headers, &mut response);
server_context.send_response(&mut response);
Result::<http::Response<axum::body::Body>, StatusCode>::Ok(response)
}
Err(SSRError::Incremental(e)) => {