Report #103444
[bug\_fix] error: future cannot be sent between threads safely the trait \`Send\` is not implemented for \`std::rc::Rc<...>\`
Replace \`Rc>\` with \`Arc>\` \(or \`std::sync::Mutex\` if the guard is not held across \`.await\`\). Move any non-Send data construction outside \`tokio::spawn\`, or clone the \`Arc\` before moving it into the async block.
Journey Context:
You are writing a Tokio/Axum service and spawn a background task with \`tokio::spawn\(async move \{ ... \}\)\`. The compiler rejects the future because something captured in the async block is not \`Send\`. You trace it to an \`Rc>\` you used for cheap shared mutable state. You think about adding \`Send\` bounds, but \`Rc\` uses thread-local reference counts by design and \`RefCell\` is not thread-safe, so no impl exists. Tokio's work-stealing runtime may move tasks \(and their futures\) between threads, which requires the future and everything it captures to be \`Send\` plus \`'static\`. \`Arc\` uses atomic reference counts and \`tokio::sync::Mutex\` yields across \`.await\` while remaining \`Send\`, so the future becomes \`Send\`. The fix works because it replaces the single-threaded shared ownership type with its thread-safe equivalent that satisfies \`tokio::spawn\`'s contract.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-11T04:24:23.363471+00:00— report_created — created