[PR #952] [MERGED] refactor(app-router): delegate RSC preload hint normalization #979

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

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/952
Author: @NathanDrake2406
Created: 4/29/2026
Status: Merged
Merged: 4/29/2026
Merged by: @james-elicx

Base: mainHead: nathan/rsc-stream-hints


📝 Commits (2)

  • f8da42c refactor(app-router): delegate RSC preload hint normalization
  • 36e34fe test(app-router): cover mixed Flight preload hints

📊 Changes

6 files changed (+178 additions, -258 deletions)

View changed files

📝 packages/vinext/src/entries/app-rsc-entry.ts (+6 -27)
packages/vinext/src/server/rsc-stream-hints.ts (+43 -0)
📝 tests/__snapshots__/entry-templates.test.ts.snap (+30 -162)
📝 tests/app-router.test.ts (+4 -69)
tests/app-rsc-stream-hints.test.ts (+85 -0)
📝 tests/entry-templates.test.ts (+10 -0)

📄 Description

What this changes

The App Router RSC entry now delegates React Flight preload hint stream normalization to a typed server helper instead of carrying the TransformStream implementation inline in generated code.

Why

The generated RSC entry should mostly contain import tables, manifests, and thin runtime wiring. Keeping byte-stream buffering and hint rewriting inside the entry made the behavior harder to test directly and kept generated snapshots responsible for runtime stream semantics.

Approach

  • Added normalizeReactFlightPreloadHints() in packages/vinext/src/server/rsc-stream-hints.ts.
  • Updated generateRscEntry() to import that helper and keep renderToReadableStream() as a one-line delegation wrapper.
  • Added direct stream tests covering complete Flight lines, split chunks, and final unterminated lines.
  • Updated generated-entry assertions and snapshots to lock down delegation instead of inline transform code.

Validation

  • vp test run tests/app-rsc-stream-hints.test.ts tests/entry-templates.test.ts
  • vp test run tests/app-router.test.ts -t "RSC Flight hint fix"
  • vp check tests/app-rsc-stream-hints.test.ts tests/entry-templates.test.ts tests/app-router.test.ts packages/vinext/src/server/rsc-stream-hints.ts packages/vinext/src/entries/app-rsc-entry.ts
  • Commit hook: tests/entry-templates.test.ts, vp check --fix, and knip --no-progress

Risks / follow-ups

This is intentionally limited to the low-conflict stream hint helper slice. It avoids metadata, middleware, ISR, route-handler cache, server action, and boundary code paths that currently have active overlapping PRs.


🔄 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/952 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 4/29/2026 **Status:** ✅ Merged **Merged:** 4/29/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `nathan/rsc-stream-hints` --- ### 📝 Commits (2) - [`f8da42c`](https://github.com/cloudflare/vinext/commit/f8da42c195e5109d28fb425514a4343c007a248a) refactor(app-router): delegate RSC preload hint normalization - [`36e34fe`](https://github.com/cloudflare/vinext/commit/36e34fe317e5de9f757f64435c7d1d56f6727bd9) test(app-router): cover mixed Flight preload hints ### 📊 Changes **6 files changed** (+178 additions, -258 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+6 -27) ➕ `packages/vinext/src/server/rsc-stream-hints.ts` (+43 -0) 📝 `tests/__snapshots__/entry-templates.test.ts.snap` (+30 -162) 📝 `tests/app-router.test.ts` (+4 -69) ➕ `tests/app-rsc-stream-hints.test.ts` (+85 -0) 📝 `tests/entry-templates.test.ts` (+10 -0) </details> ### 📄 Description ## What this changes The App Router RSC entry now delegates React Flight preload hint stream normalization to a typed server helper instead of carrying the TransformStream implementation inline in generated code. ## Why The generated RSC entry should mostly contain import tables, manifests, and thin runtime wiring. Keeping byte-stream buffering and hint rewriting inside the entry made the behavior harder to test directly and kept generated snapshots responsible for runtime stream semantics. ## Approach - Added `normalizeReactFlightPreloadHints()` in `packages/vinext/src/server/rsc-stream-hints.ts`. - Updated `generateRscEntry()` to import that helper and keep `renderToReadableStream()` as a one-line delegation wrapper. - Added direct stream tests covering complete Flight lines, split chunks, and final unterminated lines. - Updated generated-entry assertions and snapshots to lock down delegation instead of inline transform code. ## Validation - `vp test run tests/app-rsc-stream-hints.test.ts tests/entry-templates.test.ts` - `vp test run tests/app-router.test.ts -t "RSC Flight hint fix"` - `vp check tests/app-rsc-stream-hints.test.ts tests/entry-templates.test.ts tests/app-router.test.ts packages/vinext/src/server/rsc-stream-hints.ts packages/vinext/src/entries/app-rsc-entry.ts` - Commit hook: `tests/entry-templates.test.ts`, `vp check --fix`, and `knip --no-progress` ## Risks / follow-ups This is intentionally limited to the low-conflict stream hint helper slice. It avoids metadata, middleware, ISR, route-handler cache, server action, and boundary code paths that currently have active overlapping PRs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:11:22 +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#979
No description provided.