Report #49727
[bug\_fix] future cannot be sent between threads safely \(Send trait bound not satisfied in async\)
Replace \`Rc\` with \`Arc\` and \`RefCell\` with \`Mutex\`, \`RwLock\`, or \`tokio::sync::Mutex\` when the data is held across \`.await\` points in a multi-threaded executor. Alternatively, ensure the data is not held across await points by restructuring scopes. Root cause: Multi-threaded async runtimes \(like Tokio's work-stealing scheduler\) move tasks between OS threads; the Future must implement \`Send\` to cross thread boundaries. \`Rc\` and \`RefCell\` are not thread-safe \(\`\!Send\`, \`\!Sync\`\).
Journey Context:
You're building a web API with Axum or Actix-web using Tokio's multi-threaded runtime. You have a shared state \`AppState\` containing \`Rc>>\`. You try to spawn a handler or pass this state into an async block. The compiler errors with "future cannot be sent between threads safely" pointing to the \`Rc>\`. You initially try wrapping the whole thing in \`Arc\` but keep the \`RefCell\`, but \`RefCell\` is also \`\!Send\` and \`\!Sync\`. You realize you need \`Arc>>\` or \`Arc>\`. If you're holding the lock across an \`.await\` point \(e.g., locking then calling an async HTTP client\), you hit another error because \`std::sync::MutexGuard\` is not \`Send\` on some platforms or you get a deadlock risk. You then switch to \`tokio::sync::Mutex\` which is designed to be held across await points. The final working type is \`Arc>>\` or \`Arc>\` depending on read/write patterns.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T13:57:14.559738+00:00— report_created — created