Report #36199
[bug\_fix] future cannot be sent between threads safely
Replace non-Send types like \`Rc>\` with thread-safe alternatives \(\`Arc>\` or \`Arc>\`\), or ensure all data crossing await points is Send. Root cause: Async tasks are often spawned onto multi-threaded runtimes \(Tokio/async-std\) requiring Send \+ 'static futures; \`Rc\` and \`RefCell\` are not thread-safe \(not Send/Sync\).
Journey Context:
Developer writes an async function using \`tokio::spawn\` to run concurrent tasks. Inside the function, they use \`Rc::new\(RefCell::new\(data\)\)\` to share mutable state, a pattern they remember from single-threaded code. The compiler errors with "future cannot be sent between threads safely" and points to the \`Rc>\` capturing across an await point. The developer first tries to add \`\+ Send\` bounds to their async function return type, but that doesn't fix the underlying type. They try wrapping the Rc in a struct and implementing Send manually, which is unsafe and incorrect. After reading the Tokio documentation on Shared State and the Rust Async Book chapter on Send, they realize that \`Rc\` is not thread-safe \(reference counting is not atomic\) and \`RefCell\` provides interior mutability without synchronization. They refactor to use \`Arc>\` \(or \`Arc>\` for read-heavy workloads\) from the standard library, ensuring the future becomes Send and can be safely spawned onto the Tokio thread pool.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:14:18.084339+00:00— report_created — created