소스 검색

wrap fullstack rebuilds in block in place

Evan Almloff 1 년 전
부모
커밋
36ae7ec12e
1개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 2
      packages/fullstack/src/render.rs

+ 3 - 2
packages/fullstack/src/render.rs

@@ -10,6 +10,7 @@ use std::future::Future;
 use std::sync::Arc;
 use std::sync::RwLock;
 use tokio::task::JoinHandle;
+use tokio::task::block_in_place;
 
 use crate::prelude::*;
 use dioxus_lib::prelude::*;
@@ -64,7 +65,7 @@ impl SsrRendererPool {
                     let prev_context = SERVER_CONTEXT.with(|ctx| ctx.replace(server_context));
                     // poll the future, which may call server_context()
                     tracing::info!("Rebuilding vdom");
-                    vdom.rebuild(&mut NoOpMutations);
+                    block_in_place(|| vdom.rebuild(&mut NoOpMutations));
                     vdom.wait_for_suspense().await;
                     tracing::info!("Suspense resolved");
                     // after polling the future, we need to restore the context
@@ -124,7 +125,7 @@ impl SsrRendererPool {
                                         .with(|ctx| ctx.replace(Box::new(server_context)));
                                     // poll the future, which may call server_context()
                                     tracing::info!("Rebuilding vdom");
-                                    vdom.rebuild(&mut NoOpMutations);
+                                    block_in_place(|| vdom.rebuild(&mut NoOpMutations));
                                     vdom.wait_for_suspense().await;
                                     tracing::info!("Suspense resolved");
                                     // after polling the future, we need to restore the context