fix: remove possibility of SendWrapper errors on server by using conditional compilation instead of overloading .dry_resolve() (closes #4432, #4402) (#4433)

This commit is contained in:
Greg Johnston
2025-11-07 13:43:18 -05:00
committed by GitHub
parent a0d657f9b1
commit af3d6cba22
3 changed files with 12 additions and 28 deletions

View File

@@ -47,11 +47,13 @@ pub fn directive<T, P, D>(handler: D, param: P) -> Directive<T, D, P>
where
D: IntoDirective<T, P>,
{
Directive(Some(SendWrapper::new(DirectiveInner {
handler,
param,
t: PhantomData,
})))
Directive((!cfg!(feature = "ssr")).then(|| {
SendWrapper::new(DirectiveInner {
handler,
param,
t: PhantomData,
})
}))
}
/// Custom logic that runs in the browser when the element is created or hydrated.
@@ -151,13 +153,7 @@ where
Directive(inner)
}
fn dry_resolve(&mut self) {
// dry_resolve() only runs during SSR, and we should use it to
// synchronously remove and drop the SendWrapper value
// we don't need this value during SSR and leaving it here could drop it
// from a different thread
self.0.take();
}
fn dry_resolve(&mut self) {}
async fn resolve(self) -> Self::AsyncOutput {
self

View File

@@ -113,7 +113,7 @@ where
event,
#[cfg(feature = "reactive_graph")]
owner: reactive_graph::owner::Owner::current().unwrap_or_default(),
cb: Some(SendWrapper::new(cb)),
cb: (!cfg!(feature = "ssr")).then(|| SendWrapper::new(cb)),
}
}
@@ -352,13 +352,7 @@ where
}
}
fn dry_resolve(&mut self) {
// dry_resolve() only runs during SSR, and we should use it to
// synchronously remove and drop the SendWrapper value
// we don't need this value during SSR and leaving it here could drop it
// from a different thread
self.cb.take();
}
fn dry_resolve(&mut self) {}
async fn resolve(self) -> Self::AsyncOutput {
self

View File

@@ -22,7 +22,7 @@ where
{
Property {
key,
value: Some(SendWrapper::new(value)),
value: (!cfg!(feature = "ssr")).then(|| SendWrapper::new(value)),
}
}
@@ -115,13 +115,7 @@ where
}
}
fn dry_resolve(&mut self) {
// dry_resolve() only runs during SSR, and we should use it to
// synchronously remove and drop the SendWrapper value
// we don't need this value during SSR and leaving it here could drop it
// from a different thread
self.value.take();
}
fn dry_resolve(&mut self) {}
async fn resolve(self) -> Self::AsyncOutput {
self