Skip to content

Commit

Permalink
fix: correctly support !Send Actix APIs in server functions (#3326)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
gbj and autofix-ci[bot] authored Dec 7, 2024
1 parent be3c181 commit 2aa9827
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server_fn_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@ pub fn server_macro_impl(
})
.collect::<Result<Vec<_>>>()?;

// 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::<ServerFnArgs>(args.into())?;
Expand Down

0 comments on commit 2aa9827

Please sign in to comment.