[PR #840] [CLOSED] feat(app-router): filter skipped layouts from RSC responses and cached reads [3/6] #889

Closed
opened 2026-05-06 13:10:40 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/840
Author: @NathanDrake2406
Created: 4/14/2026
Status: Closed

Base: mainHead: feat/pr-768-3-skip-filter-server


📝 Commits (3)

  • 4c2f81f feat(app-router): filter skipped layouts from RSC responses and cached reads
  • bc703d5 fix(app-router): address skip-filter review feedback
  • 73d9224 fix(app-router): tighten dormant skip-filter defaults

📊 Changes

10 files changed (+1617 additions, -6 deletions)

View changed files

📝 packages/vinext/src/entries/app-rsc-entry.ts (+9 -0)
📝 packages/vinext/src/server/app-elements.ts (+46 -0)
📝 packages/vinext/src/server/app-page-cache.ts (+12 -1)
📝 packages/vinext/src/server/app-page-render.ts (+25 -5)
packages/vinext/src/server/app-page-skip-filter.ts (+340 -0)
📝 tests/__snapshots__/entry-templates.test.ts.snap (+54 -0)
📝 tests/app-elements.test.ts (+89 -0)
📝 tests/app-page-cache.test.ts (+156 -0)
📝 tests/app-page-render.test.ts (+384 -0)
tests/app-page-skip-filter.test.ts (+502 -0)

📄 Description

Summary

PR 3 of 6 — restack of #768. Stacked on #839.

Introduces `app-page-skip-filter.ts` with the canonical-bytes guarantee: the render path always produces the full RSC payload and writes it to the cache; the egress branch applies a byte-level filter that omits layouts the client asked to skip, but only if the server independently classified them as static (`computeSkipDecision`).

Wires the filter into `renderAppPageLifecycle` and `buildAppPageCachedResponse` so both fresh renders and cache hits honor the skip header. Parses the incoming `X-Vinext-Router-Skip` header at the handler scope and threads the resulting set through render and ISR.

Dormant until canonical-stream is validated: gated behind `supportsFilteredRscStream: false` in the generated entry so this PR lands inert at runtime. Tests exercise the filter directly by injecting the skip set into `renderAppPageLifecycle` options.

Canonical-bytes invariant

  1. `rscStream` is rendered from the canonical element (never mutated).
  2. `teeAppPageRscStreamForCapture` splits into `capturedRscDataPromise` (→ cache) and `responseStream` (→ client).
  3. The filter only applies to `responseStream` when `isRscRequest && supportsFilteredRscStream !== false && skipIds.size > 0`.
  4. The cache therefore always sees full bytes regardless of client skip state.

Stack

  1. [1/6] #838 — centralize request-derived page inputs
  2. [2/6] #839 — emit per-layout flags in the RSC payload
  3. [3/6] this PR — filter skipped layouts from RSC responses and cached reads
  4. [4/6] send X-Vinext-Router-Skip on navigation requests
  5. [5/6] wire build-time layout classification
  6. [6/6] classification reasons sidecar

Test plan

  • `tests/app-page-skip-filter.test.ts` (44 tests)
  • `tests/app-page-cache.test.ts` (17 tests)
  • `tests/app-page-render.test.ts` (21 tests, includes skip-filter section)
  • Verified tests pass WITHOUT client header wiring from PR 4

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/840 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 4/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/pr-768-3-skip-filter-server` --- ### 📝 Commits (3) - [`4c2f81f`](https://github.com/cloudflare/vinext/commit/4c2f81fecb5ee5a152f367eca35d7ff6a0699dc2) feat(app-router): filter skipped layouts from RSC responses and cached reads - [`bc703d5`](https://github.com/cloudflare/vinext/commit/bc703d564e81a1451af891fc844b377c6efbe7f9) fix(app-router): address skip-filter review feedback - [`73d9224`](https://github.com/cloudflare/vinext/commit/73d92243c9308c0e6ac26f74149277d6bc7dc4d6) fix(app-router): tighten dormant skip-filter defaults ### 📊 Changes **10 files changed** (+1617 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+9 -0) 📝 `packages/vinext/src/server/app-elements.ts` (+46 -0) 📝 `packages/vinext/src/server/app-page-cache.ts` (+12 -1) 📝 `packages/vinext/src/server/app-page-render.ts` (+25 -5) ➕ `packages/vinext/src/server/app-page-skip-filter.ts` (+340 -0) 📝 `tests/__snapshots__/entry-templates.test.ts.snap` (+54 -0) 📝 `tests/app-elements.test.ts` (+89 -0) 📝 `tests/app-page-cache.test.ts` (+156 -0) 📝 `tests/app-page-render.test.ts` (+384 -0) ➕ `tests/app-page-skip-filter.test.ts` (+502 -0) </details> ### 📄 Description ## Summary **PR 3 of 6 — restack of #768. Stacked on #839.** Introduces \`app-page-skip-filter.ts\` with the canonical-bytes guarantee: the render path always produces the full RSC payload and writes it to the cache; the egress branch applies a byte-level filter that omits layouts the client asked to skip, but only if the server independently classified them as static (\`computeSkipDecision\`). Wires the filter into \`renderAppPageLifecycle\` and \`buildAppPageCachedResponse\` so both fresh renders and cache hits honor the skip header. Parses the incoming \`X-Vinext-Router-Skip\` header at the handler scope and threads the resulting set through render and ISR. **Dormant until canonical-stream is validated:** gated behind \`supportsFilteredRscStream: false\` in the generated entry so this PR lands inert at runtime. Tests exercise the filter directly by injecting the skip set into \`renderAppPageLifecycle\` options. ## Canonical-bytes invariant 1. \`rscStream\` is rendered from the canonical element (never mutated). 2. \`teeAppPageRscStreamForCapture\` splits into \`capturedRscDataPromise\` (→ cache) and \`responseStream\` (→ client). 3. The filter only applies to \`responseStream\` when \`isRscRequest && supportsFilteredRscStream !== false && skipIds.size > 0\`. 4. The cache therefore always sees full bytes regardless of client skip state. ## Stack 1. [1/6] #838 — centralize request-derived page inputs 2. [2/6] #839 — emit per-layout flags in the RSC payload 3. **[3/6] this PR** — filter skipped layouts from RSC responses and cached reads 4. [4/6] send X-Vinext-Router-Skip on navigation requests 5. [5/6] wire build-time layout classification 6. [6/6] classification reasons sidecar ## Test plan - [x] \`tests/app-page-skip-filter.test.ts\` (44 tests) - [x] \`tests/app-page-cache.test.ts\` (17 tests) - [x] \`tests/app-page-render.test.ts\` (21 tests, includes skip-filter section) - [x] Verified tests pass WITHOUT client header wiring from PR 4 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:10:40 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#889
No description provided.