Skip to content

Conversation

@Simon-Laux
Copy link
Contributor

@Simon-Laux Simon-Laux commented Sep 9, 2022

these two functions don't compile, I get this error:

error: generator cannot be sent between threads safely --> deltachat-jsonrpc/src/api/mod.rs:74:1 | 74 | #[rpc(all_positional, ts_outdir = "typescript/generated")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` | = help: the trait `Sync` is not implemented for `core::fmt::Opaque` = note: required for the cast to the object type `dyn Future<Output = Result<Value, yerpc::Error>> + Send` = note: this error originates in the attribute macro `rpc` (in Nightly builds, run with -Z macro-backtrace for more info) error: could not compile `deltachat-jsonrpc` due to previous error cargo failed with code 101 

any ideas what we need to change in order to fix it?

also if you try it out, I recommend uncommenting one of those functions because both have similar errors so you might not notice at a glance if you
fixed it.

@Hocuri
Copy link
Collaborator

Hocuri commented Sep 10, 2022

For the get_connectivity_html() problem: The problem is that #[rpc(...)] requires all futures to be Send, so you can't hold a fmt argument over an await point, so you can't use await in format!.

I found this out by commenting parts of get_connectivity_html() until I knew where the error was, and by using rust-analyzer's Expand macro recursively on the #[rpc(...)]. I think the Rust compiler could handle this better; I created a reproducible example at https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d20021c1f59736781ee3641d50797820 and will report this upstream, maybe it's fixable (maybe not, we'll see).

You will have to replace all these code parts:

 ret += &format!( "<h3>{}</h3><ul><li>", stock_str::outgoing_messages(self).await );

by e.g.:

 let stock_outgoing_msgs = stock_str::outgoing_messages(self).await; ret += &format!("<h3>{}</h3><ul><li>", stock_outgoing_msgs);

I didn't look at the other problem yet, or maybe you can fix it yourself.

@Jikstra
Copy link
Contributor

Jikstra commented Sep 10, 2022

Fixed them thanks to @Hocuri discoveries :)

@Jikstra Jikstra merged commit f3a38d7 into jsonrpc-add-missing-functions-for-making-message-list-work-in-desktop Sep 10, 2022
@Jikstra Jikstra deleted the jsonrpc-func-failing-to-compile-lets-find-out-why branch September 10, 2022 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants