mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
2824b7653a
* fix(router): replace stale optimistic layouts across dynamic params A detached optimistic shell can commit stale dynamic-layout output before the authoritative payload resolves. Preparing the latter from live router state then makes the shell appear current, so stale server props and BFCache identity survive a cross-param navigation. All payloads in one navigation must derive reuse identity from the same initiation state. Capture that state once and pass it through commit preparation, while live router state remains the authority for cancellation and commit approval. Add composition coverage for cross-param replacement, same-param preservation, and layout-owned slots, plus a deterministic browser regression for the prefetched-shell handoff. * fix(router): require navigation initiation state for payload preparation Navigation payload callers could omit the initiation state and silently prepare from live router state. A future caller could therefore compile while reintroducing the optimistic-to-authoritative identity bug. Require the state at both browser-entry and controller boundaries and remove the live-state fallback. Isolated controller tests now choose current-state preparation through an explicitly named test helper. * test(router): synchronize payload tests on state dispatch Navigation payload regressions advanced a fixed number of microtasks before reading router state. That coupled the tests to the controller's current async scheduling depth.\n\nExpose a one-shot visible-commit dispatch waiter from the controller harness and await that explicit boundary before assertions. * docs(router): document the currentState baseline in createPendingNavigationCommit createPendingNavigationCommit's currentState param has no note on what it should be. Navigation callers now pass the frozen navigation-initiation state (per the previous two commits), while the HMR caller still passes live state, and nothing marks that split as deliberate. A future navigation call site that passes live state instead of the initiation state would silently reintroduce the stale cross-param reuse bug this branch fixes, with no type error to catch it. Document the invariant on the field so the split reads as intentional. --------- Co-authored-by: James <james@eli.cx>