Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atrium_xrpc_server isn't compatible with tokio::spawn #20

Closed
str4d opened this issue May 26, 2023 · 1 comment · Fixed by #21
Closed

atrium_xrpc_server isn't compatible with tokio::spawn #20

str4d opened this issue May 26, 2023 · 1 comment · Fixed by #21

Comments

@str4d
Copy link
Contributor

str4d commented May 26, 2023

atrium_xrpc_server::stream::frames::Frame::try_from returns Result<Self, Box<dyn std::error::Error>>. The problem is that dyn std::error::Error is not Send, which means that if the result of Frame::try_from is potentially used across an await, the entire future is not Send.

To reproduce this, modify the firehose example to spawn the firehose running method instead of running it directly with #[tokio::main]. I tested this at commit 7d99ccd.

It would be helpful if the error type was Send + Sync + 'static, to also make it compatible with the anyhow crate. But that can be handled by rewriting the error as a string, whereas the future not being Send is more problematic for usage.

@sugyan
Copy link
Owner

sugyan commented May 29, 2023

Thank you for your report! I modified atrium-xrcp-server to use anyhow::Error and confirmed that it works with the following change in firehose example.

    tokio::spawn(async move {
        let _ = process_message(&message).await;
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants