Report #44586
[bug\_fix] trait bound \`Rc>: Send\` is not satisfied when spawning async tasks
Replace \`Rc\` with \`Arc\` and \`RefCell\` with a thread-safe lock like \`std::sync::Mutex\` or \`tokio::sync::Mutex\`. For async code, prefer \`Arc>\` to avoid blocking the executor. If the type truly cannot be \`Send\`, use \`tokio::task::LocalSet\` to spawn \`\!Send\` tasks on a single thread.
Journey Context:
Developer writes an async web server using \`tokio::spawn\` to handle requests. They use \`Rc>\` to share mutable state between tasks. Compiler errors saying \`Rc\` is not \`Send\`. Developer tries to use \`unsafe impl Send\` which leads to data races. They learn that \`Rc\` is thread-unsafe by design. They replace it with \`Arc>\` using \`std::sync::Mutex\` but find that locking across \`.await\` points causes panics or deadlocks. They finally settle on \`Arc>\` which is designed for async contexts. The code compiles and runs safely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T05:18:19.973538+00:00— report_created — created