Repository navigation
Commit 09550a7
authored
fix(router): floor the new-segment seed so revalidate() cannot blank an unrendered parallel slot (#814)
A parallel() slot carrying revalidate(() => false) never appeared when the route
owning it was reached by soft navigation, while a direct load of the same URL
rendered it fine. Reported against tests/vite-rsc-demo: land on
/shop/product/:slug, click through to /shop, and the category sidebar stays
blank until a full reload. Whether the slot showed up depended on the order the
user happened to navigate in.
The slot id is absent from the partial request's client-segment set because the
product page never rendered it. resolveParallelSegmentsWithRevalidation seeds
that case "new-segment" (render it), then passes the seed to
evaluateRevalidation, where the user's hard `false` overrode it — emitting
component:null for a slot the client had nothing cached to fall back on.
The three sibling resolvers (loaders, layout/route entries, orphan layouts)
never had this bug because they express the same invariant as an unconditional
early return that never consults user predicates. The parallel path cannot copy
that shape: #482 deliberately made it consult predicates for an unknown slot so
a "skip-parent-chain" seed could still be raised, and because evaluateRevalidation
re-throws a Response from a predicate as control flow, an early return would
silently drop revalidate(() => { throw redirect(...) }).
So the seed is floored rather than short-circuited. defaultOverride gains an
optional `floor`; evaluateRevalidation applies it at all three exits through a
new local decide(), so predicates still run and may only raise the decision.
Applying it inside evaluateRevalidation rather than clamping the returned
boolean at the call site keeps the revalidation trace to one entry per segment —
an outer clamp pushed a second, contradicting entry, and flushRevalidationTrace
buckets by finalShouldRevalidate with no dedup by segmentId, so the slot was
counted as both revalidated and skipped and `total` was inflated.
revalidate() now means "render once, then never refetch" rather than "sometimes
never appear at all". Once the slot is on the client the seed is unfloored and a
`false` is honored exactly as before, as are a `true` and a thrown Response in
every case.
Regression tests proven red before green: parallel-revalidate-fns-invocation.test.ts
gains six tests covering the floored seeds (belongsToRoute, isNewParent, orphan
force-render, and soft {defaultShouldRevalidate: false}, which exits by a
different path than a hard false) plus the two cases that must NOT floor —
client already has the slot, and the skip-parent-chain seed — without which
"floor to true" could widen into "parallel slots always render".
revalidation-trace-pipeline.test.ts gains two tests pinning one trace entry per
decision, verified to fail against the double-push shape. Dev and production e2e
in three apps: the router test-app and cloudflare-basic (workerd) via a reduced
fixture, and vite-rsc-demo driving the reported /shop routes with no new fixture;
each has a direct-load control so a broken fixture is distinguishable from a
broken soft nav.
The client-knowledge seed invariant, previously implicit in five differently
shaped code blocks with no name, is now stated in docs/internal/execution-model.md
with a table of which resolver uses which shape and why the parallel path
diverges. skills/parallel/SKILL.md covers the consumer half.
Not done: a general floor adopted by the sibling resolvers. Each would have to
start calling evaluateRevalidation unconditionally, invoking user predicates on
paths that never have — reversing #482's deliberate sibling audit. No userland
test through @rangojs/router/testing either: dispatch is RSC-free by design and
rejects partial requests to component routes, and renderRoute is client-only, so
no primitive can reach a partial component-route render.
Also carries an unrelated test fix. default-prefetch-none's intersection test
asserted one /assets/runtime-*.js fetch, but #809 folded the prefetch runtime
into the eager router chunk precisely so that fetch would stop happening, making
the production assertion unsatisfiable. #809 updated build-test-app.setup.ts and
the manual-chunks unit tests but not this assertion, and its merge-time run
skipped cloudflare-basic-e2e via path filtering, so it landed unnoticed; main's
scheduled runs had been red on it since 2026-07-24. The count is mode-dependent —
dev still serves browser/prefetch/runtime.ts as its own unbundled module — so it
is flipped to a mode-aware check rather than deleted, turning a stale expectation
into a guard for the invariant #809 established.1 parent 9418275 commit 09550a7
16 files changed
Lines changed: 783 additions & 14 deletions
File tree
- packages/rangojs-router
- docs/internal
- e2e
- test-app/src
- urls
- skills/parallel
- src/router
- __tests__
- segment-resolution
- tests
- cloudflare-basic
- e2e
- src
- pages
- vite-rsc-demo/e2e
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
663 | 684 | | |
664 | 685 | | |
665 | 686 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| 257 | + | |
| 258 | + | |
257 | 259 | | |
258 | 260 | | |
259 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
1004 | 1005 | | |
1005 | 1006 | | |
1006 | 1007 | | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
1007 | 1014 | | |
1008 | 1015 | | |
1009 | 1016 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
377 | 387 | | |
378 | 388 | | |
379 | 389 | | |
| |||
0 commit comments