[backport] turbo-tasks-backend: fix strongly consistent read hanging on a canceled task (#98931)
Backports #98312 ("turbo-tasks-backend: fix strongly consistent read
hanging on a canceled task") to `next-16-3`.
### What?
`next build` could hang at shutdown on the 16.3 line: a strongly
consistent read would wait forever on a task that shutdown had already
canceled, which in turn blocked `stop_and_wait`. This brings the
upstream fix, and its regression test, to the release branch.
### Why?
A canceled task has no output, and `has_output()` is used as the proxy
for "not computed yet". Shutdown therefore made the canceled child look
like work still to be scheduled: it was marked dirty and contributed a
dirty container that could never drain, because the (clean) parent never
re-evaluates `all_clean_event`. The strongly consistent reader waited on
that event indefinitely while holding a foreground job that shutdown
blocks on.
### How?
The fix records a terminal error output when a task execution is
canceled, so a canceled task is no longer indistinguishable from an
uncomputed one and the dirty-container accounting drains as it should.
It also makes the `hanging_detection` feature usable again, which
previously panicked on a `data` access check.
The source change is the upstream one, unmodified. One release-branch
adaptation was required: the backported regression test pulls in a
shared `tests/util.rs` helper that does not exist on `next-16-3` — it
was extracted on `canary` by unrelated later commits. A minimal version
is added here, providing only the persistent-backend setup the test
needs and written against this branch's APIs (`BackendOptions` has no
`gc` field here, and `turbo_backing_storage` still takes positional
`is_ci` / `is_short_session` / `skip_compaction` arguments). It follows
the same shape as the existing inline helper in `tests/eviction.rs`.
### Verification
- The regression test was run against an unmodified `next-16-3`
checkout, where it reproduces the bug: it hangs and fails after 30s with
"stop_and_wait hung: a cancelled task stranded a strongly consistent
reader". With this change it passes.
- `cargo fmt --check`, `cargo clippy -p turbo-tasks-backend
--all-targets` and the full `cargo test -p turbo-tasks-backend` suite
are clean.
- `pnpm build-all` succeeds.
<!-- NEXT_JS_LLM -->
<!-- fleet 33c5c205-5580-40f2-bcf8-5f91a945ef4b -->
Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment