multiple fullstack nits/cleanups before release (#4852)

* feat: `:arg` syntax for serverfn

* add better decode/encode verify message

* allow catch-all query args

* add rebind

* implement websocket frames for `Streaming`

* fix lazy init

* wip... serverfnstate

* wip...

* wip: serverfns require Send/Sync, let's fix that

* wip...

* small cleanup

* fix hang by actually spawning the tokio task

* clippy

* fix parameter catchall binding

* fix lychee

* doc tests
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2025-10-30 18:52:47 -07:00
1 parent 43373f0be7
commit 5559e463c8
27 files changed
+1395 -1097

No files matched your search

+4 -31
View File
@@ -21,12 +21,11 @@ use http::{request::Parts, HeaderMap, StatusCode};
use std::{
collections::HashMap,
fmt::Write,
future::Future,
iter::Peekable,
rc::Rc,
sync::{Arc, RwLock},
};
use tokio::task::JoinHandle;
use tokio_util::task::LocalPoolHandle;
use crate::StreamingMode;
@@ -99,6 +98,7 @@ impl SsrRendererPool {
self: Arc<Self>,
parts: Parts,
cfg: &ServeConfig,
rt: &LocalPoolHandle,
virtual_dom_factory: impl FnOnce() -> VirtualDom + Send + Sync + 'static,
) -> Result<
(
@@ -420,7 +420,8 @@ impl SsrRendererPool {
myself.renderers.write().unwrap().push(renderer);
};
let join_handle = Self::spawn_platform(create_render_future);
// Spawn the render future onto the local pool
let join_handle = rt.spawn_pinned(create_render_future);
// Wait for the initial result which determines the status code
let (status, headers) = initial_result_rx
@@ -763,32 +764,4 @@ impl SsrRendererPool {
Ok(())
}
/// Spawn a task in the background. If wasm is enabled, this will use the single threaded tokio runtime
fn spawn_platform<Fut>(f: impl FnOnce() -> Fut + Send + 'static) -> JoinHandle<Fut::Output>
where
Fut: Future + 'static,
Fut::Output: Send + 'static,
{
#[cfg(not(target_arch = "wasm32"))]
{
use tokio_util::task::LocalPoolHandle;
static TASK_POOL: std::sync::OnceLock<LocalPoolHandle> = std::sync::OnceLock::new();
let pool = TASK_POOL.get_or_init(|| {
LocalPoolHandle::new(
std::thread::available_parallelism()
.map(usize::from)
.unwrap_or(1),
)
});
pool.spawn_pinned(f)
}
#[cfg(target_arch = "wasm32")]
{
tokio::task::spawn_local(f())
}
}
}