Repository navigation
fix(ppr): reevaluate transition gates on replay - #776
Merged
Merged
Conversation
…sition-when # Conflicts: # packages/rangojs-router/docs/internal/execution-model.md
commit: |
…sition-when # Conflicts: # packages/rangojs-router/docs/design/ppr-shell-resume.md # packages/rangojs-router/docs/internal/execution-model.md # packages/rangojs-router/e2e/shell-cache.test.ts # packages/rangojs-router/skills/ppr/SKILL.md # tests/cloudflare-basic/e2e/ppr-shell.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A consumer can combine
pprwithtransition({ when }), but a warmed partial navigation currently rejects the captured PPR segment snapshot solely because the shell records that a conditional transition exists. The route handler then reruns even though only the request-specific transition decision changed. On dispatcher-style routes this turns a replay hit into the full CMS/catalog handler path.Closes #772.
Before vs. after
Before, this valid route captures a shell but partial navigations bypass its segment replay:
After, consumer code is unchanged. The router reuses the captured segment record and evaluates only the server-side predicate for the current request:
Consumers who do not use
pprortransition({ when })see no behavior change.End-to-end example
Navigating within one category keeps the transition hold. Navigating across categories drops it and streams
ProductSkeleton, while both paths can reuse the warmed PPR handler segments and continue running loaders fresh.Semantics
cache()/prerender hitrenderingCode changes
src/router/transition-when.tsowns shared context construction and manifest-based PPR predicate evaluation, including route, orphan-layout, and parallel-slot segment IDs.src/router/match-handlers.tsevaluates PPR predicates after route middleware has established context but before the segment pipeline performs cache lookup.src/router/match-middleware/cache-lookup.tsretains predicate-owning replay segments so a fresh keep/drop decision reaches the client even when the component otherwise needs no update.src/rsc/transition-gate.tsapplies PPR decisions copy-on-write, preserving reusable cache, prerender, and shell records. Ordinary post-handler gating remains in place.src/testing/run-transition-when.tsadds{ ppr: true }so consumers can test the production pre-handler timing through@rangojs/router/testing.The predicate is evaluated from the already matched manifest rather than forcing normal segment resolution, because rerunning handlers would defeat the PPR replay contract this fixes.
Test plan
transition-when.test.ts: PPR pre-handler context, keep/drop results, route/orphan/parallel IDs, throwing behavior, and reusable-record immutability through the public testing primitive.[PPR4]: conditional predicates rerun while PPR handlers replay, in dev and production (71 rows passed).cloudflare-basic: the same document, partial replay, and fresh drop contracts on workerd, in dev and production (6 focused cases passed).pnpm run typecheckpnpm run test:unit:allpnpm run lintpnpm run formatNotes
main, including feat(ppr): expose navigation replay hits #774'sx-rango-ppr-replaysignal; the replay e2e now asserts that signal.