A better Rust ATProto crate
99
fork

Configure Feed

Select the types of activity you want to include in your feed.

Setting base_uri on XrpcClient causes panic with tokio current_thread #12

open opened by blooym.dev

When XrpcClient's base_uri setter is called (at least on the OAuthSession implementation), tokio will panic when using the current_thread flavor with the error message can call blocking only when running on the multi-threaded runtime.

The snippet that causes the panic is:

fn base_uri(&self) -> Url {
    // base_uri is a synchronous trait method; we must avoid async `.read().await`.
    // Use `block_in_place` under Tokio runtime to perform a blocking RwLock read safely.
    #[cfg(not(target_arch = "wasm32"))]
    if tokio::runtime::Handle::try_current().is_ok() {
        return tokio::task::block_in_place(|| self.data.blocking_read().host_url.clone());
    }

    self.data.blocking_read().host_url.clone()
}

This can be reproduced by implementing a basic OAuth flow as described in the docs and using #[tokio::main(flavor = "current_thread")]

sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:p5yjdr64h7mk5l3kh6oszryk/sh.tangled.repo.issue/3m3fgxoll6n22