Report #14709
[bug\_fix] future cannot be sent between threads safely
Replace \`Rc\` with \`Arc\` and \`RefCell\` with \`Mutex\` or \`RwLock\` \(e.g., \`Arc>\`\), ensuring all data held across \`.await\` points implements \`Send\`. Alternatively, use \`tokio::task::LocalSet\` for \!Send futures.
Journey Context:
Developer builds an Axum web handler that maintains shared state using \`Rc>>\`. They try to spawn a background task with \`tokio::spawn\(async move \{ ... \}\)\` that captures the state. The compiler errors with 'future cannot be sent between threads safely', noting that \`Rc>\` is not \`Send\`. Developer tries wrapping in \`Arc>\` but RefCell is not Sync/Send either. They try \`Arc>\` using \`std::sync::Mutex\` but worry about blocking the async runtime. They eventually switch to \`Arc>>\` which is Send \+ Sync and async-aware. The fix works because Tokio's work-stealing scheduler moves tasks between threads at await points; all data in a spawned task must be Send to allow this thread migration. Rc and RefCell are thread-unsafe by design, so their thread-safe counterparts \(Arc, Mutex/RwLock\) must be used.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:16:33.588698+00:00— report_created — created