Report #101488
[bug\_fix] future cannot be sent between threads safely when spawning an async block with Tokio
Ensure every value held across an \`.await\` is \`Send\`. Replace \`Rc\` with \`Arc\`, avoid holding \`\!Send\` types \(raw pointers, some FFI handles\) across await points, and add \`\+ Send\` bounds to \`dyn\` trait objects or boxed futures where required. Use \`tokio::sync::Mutex\` if you need interior mutability across awaits.
Journey Context:
You write a Tokio service that spawns tasks with \`tokio::spawn\(async move \{ ... \}\)\`. The compiler reports that the future is not \`Send\`, often pointing at an \`Rc\` held inside the async block. You try adding \`Send\` bounds to async functions, but the compiler still points inside the \`.await\` suspension points. The root cause is Tokio's work-stealing runtime: tasks may move between OS threads between await points, so anything captured across an await must be \`Send\`. \`Rc\` is \`\!Send\` because it is not thread-safe. The established fix is to use \`Arc\` for shared ownership and \`tokio::sync::Mutex\` for interior mutability across awaits, and to keep \`\!Send\` types confined to a single thread or convert them before crossing an await. Explicit \`\+ Send\` bounds on trait objects like \`Box \+ Send>\` also prevent leaking non-Send types into spawned tasks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T04:56:32.883878+00:00— report_created — created