[GH-ISSUE #236] Futures are not Send #80

Closed
opened 2026-02-27 20:22:59 +03:00 by kerem · 3 comments
Owner

Originally created by @kebabtent on GitHub (Aug 6, 2021).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/236

Originally assigned to: @marioortizmanero on GitHub.

I am using the latest commit in the master branch. The futures produced by the client are not Send, meaning the client cannot be used inside a spawned task. Is there any way around it or are there plans to resolve it?

Minimal example:

#[tokio::main]
async fn main() {
    tokio::spawn(spotify());
}

async fn spotify() {
    let creds = rspotify::Credentials::from_env().unwrap();
    let mut spotify = rspotify::ClientCredsSpotify::new(creds);
    spotify.request_token().await.unwrap();
}
Originally created by @kebabtent on GitHub (Aug 6, 2021). Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/236 Originally assigned to: @marioortizmanero on GitHub. I am using the latest commit in the master branch. The futures produced by the client are not `Send`, meaning the client cannot be used inside a spawned task. Is there any way around it or are there plans to resolve it? Minimal example: ```rust #[tokio::main] async fn main() { tokio::spawn(spotify()); } async fn spotify() { let creds = rspotify::Credentials::from_env().unwrap(); let mut spotify = rspotify::ClientCredsSpotify::new(creds); spotify.request_token().await.unwrap(); } ```
kerem 2026-02-27 20:22:59 +03:00
Author
Owner

@marioortizmanero commented on GitHub (Aug 7, 2021):

Hmm. The futures are Send if ureq is being used, but not for reqwest. I'll investigate more, but it doesn't seem to be async_trait's fault.

<!-- gh-comment-id:894638400 --> @marioortizmanero commented on GitHub (Aug 7, 2021): Hmm. The futures are `Send` if `ureq` is being used, but not for `reqwest`. I'll investigate more, but it doesn't seem to be `async_trait`'s fault.
Author
Owner

@marioortizmanero commented on GitHub (Aug 7, 2021):

Ok, this seems to be a side effect of using #[async_trait(?Send)] for the BaseClient trait. I used it at the beginning so that the function signatures would be simpler but it seems we do need Send.

<!-- gh-comment-id:894639782 --> @marioortizmanero commented on GitHub (Aug 7, 2021): Ok, this seems to be a side effect of using `#[async_trait(?Send)]` for the `BaseClient` trait. I used it at the beginning so that the function signatures would be simpler but it seems we do need `Send`.
Author
Owner

@marioortizmanero commented on GitHub (Aug 7, 2021):

This is fixed by #237

<!-- gh-comment-id:894641290 --> @marioortizmanero commented on GitHub (Aug 7, 2021): This is fixed by #237
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/rspotify#80
No description provided.