turbo
337b2e82 - fix: Prevent panic in turbo watch with persistent tasks (#12459)

Commit
5 days ago
fix: Prevent panic in turbo watch with persistent tasks (#12459) ## Summary Fixes #12458 - `turbo watch` panics at `visitor/mod.rs:564` because `Arc::into_inner` requires the strong reference count to be exactly 1, but fire-and-forget persistent tasks (spawned at line 491) still hold `Arc` clones of the shared error collector when `visit()` returns. - Uses `Arc::try_unwrap` with a fallback that locks the mutex and drains collected errors when outstanding references remain, which is the expected case in watch mode with persistent tasks. ## How it works In watch mode, persistent tasks (e.g. `vite dev`) are intentionally spawned as fire-and-forget -- the `JoinHandle` is dropped immediately so dependent tasks can proceed. Each of these detached spawns holds a `TaskErrorCollectorWrapper(Arc<Mutex<Vec<TaskError>>>)`. Since persistent tasks run indefinitely, these `Arc` clones are never dropped before the end of `visit()`. The previous code assumed all `Arc` clones would be gone by the time it called `Arc::into_inner`, which is only true for the non-watch code path where every task is tracked in `FuturesUnordered` and drained.
Author
Parents
Loading