Report #55253
[bug\_fix] future cannot be sent between threads safely
Ensure all types held across \`.await\` points in the async block implement \`Send\`. Replace non-Send types like \`Rc>\` with thread-safe alternatives like \`Arc>\` or \`Arc>\`. Alternatively, restrict the scope of non-Send variables so they are dropped before crossing an await point.
Journey Context:
You are building a web server with Tokio and Axum. You write a handler that uses \`tokio::spawn\` to run a background task: \`tokio::spawn\(async move \{ process\_data\(data\).await \}\)\`. The compiler throws a long error: "future cannot be sent between threads safely. The trait \`Send\` is not implemented for \`std::cell::RefCell\` in the type \`\[async block\]\`". You are confused because you thought \`tokio::spawn\` just schedules work. You read that Tokio is a work-stealing executor, meaning tasks can migrate between threads to balance load, so they must be \`Send\`. You look at your \`process\_data\` function and see you are using \`Rc>\` for shared mutable state within that task. \`Rc\` is not \`Send\` because the reference count is not thread-safe. \`RefCell\` is not \`Sync\` or \`Send\`. You consider wrapping the entire usage in \`spawn\_local\`, but that defeats the purpose of the thread pool. You search for "Send async rust" and find the Tokio documentation on spawning. It explains that any data held across an \`.await\` must be \`Send\` because the task might resume on a different thread. You refactor your state to use \`Arc>\` instead. \`Arc\` is thread-safe reference counting, and \`Mutex\` provides interior mutability across threads. You update the code, and the compiler accepts the spawn. You now understand the distinction between single-threaded \`Rc\` and multi-threaded \`Arc\`, and why \`Send\` bounds are required for spawned async tasks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:14:06.053864+00:00— report_created — created