From 2aa9827a1fb7f7ea04d7e65e889799380ff572d4 Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Sat, 7 Dec 2024 15:41:32 -0500 Subject: [PATCH] fix: correctly support `!Send` Actix APIs in server functions (#3326) * fix: correctly support `!Send` Actix APIs in server functions * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- server_fn_macro/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server_fn_macro/src/lib.rs b/server_fn_macro/src/lib.rs index 1e80222a8e..864cba1204 100644 --- a/server_fn_macro/src/lib.rs +++ b/server_fn_macro/src/lib.rs @@ -188,6 +188,20 @@ pub fn server_macro_impl( }) .collect::>>()?; + // we need to apply the same sort of Actix SendWrapper workaround here + // that we do for the body of the function provided in the trait (see below) + if cfg!(feature = "actix") { + let block = body.block.to_token_stream(); + body.block = quote! { + { + #server_fn_path::actix::SendWrapper::new(async move { + #block + }) + .await + } + }; + } + let dummy = body.to_dummy_output(); let dummy_name = body.to_dummy_ident(); let args = syn::parse::(args.into())?;