Report #7417
[bug\_fix] future cannot be sent between threads safely
Ensure all types held across \`.await\` points implement \`Send\`, or bound the future with \`Send\`. If using non-Send types like \`Rc\` or a non-Send receiver, either convert to \`Arc\`/\`Mutex\` or use \`tokio::task::spawn\_local\` for single-threaded execution. Root cause: Tokio's work-stealing scheduler may move tasks between OS threads; it requires the future and all its captured state to be \`Send\` for thread-safety.
Journey Context:
An async Rust developer is writing a background task processor with Tokio. They spawn a task using \`tokio::spawn\` that receives messages from an async channel. The code compiles until they add a non-Send type, like an \`Rc>\` or a \`LocalSet\` handle. The compiler error points to the \`.await\` point inside the async block, stating the future cannot be sent between threads. The developer first tries wrapping everything in \`Arc>\` but still fails because the future itself captures non-Send types. They realize the issue is that \`tokio::spawn\` requires \`Send\` because the task might run on different threads in the runtime. The fix involves either ensuring all data crossing await points is Send \(using Arc instead of Rc, Mutex instead of RefCell\), or if the data must be thread-local, using \`spawn\_local\` which pins the task to the current thread.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:41:02.223095+00:00— report_created — created