Report #98705
[bug\_fix] future cannot be sent between threads safely because \`Rc>\` is not \`Send\` / \`Sync\`
Replace \`Rc>\` with \`Arc>\` \(or \`Arc>\`\) in async code that runs on a multi-threaded runtime. If the data is read-only after creation, \`Arc\` alone is sufficient. Avoid \`RefCell\` across await points because it is not \`Sync\` and panics at runtime on concurrent access; use async-aware locks instead.
Journey Context:
You start a \`tokio::main\` multi-threaded runtime and spawn async tasks that share state with \`Rc>>\`. The compiler rejects the future as not \`Send\` because \`Rc\` and \`RefCell\` are not thread-safe. You try wrapping only the \`RefCell\` in \`Arc\` and still fail because \`RefCell\` itself is not \`Sync\`. You switch to \`Arc>\` using \`std::sync::Mutex\`, but blocking the async runtime inside \`.lock\(\)\` causes performance issues and potential deadlocks. You finally use \`tokio::sync::RwLock\` with \`.read\(\).await\` and \`.write\(\).await\`, keeping the future \`Send\` and avoiding blocking the executor. You also realize the state does not need interior mutability if you only modify it during setup, so \`Arc\` works for the read-only case.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-28T04:38:46.685685+00:00— report_created — created