[PR #619] [MERGED] refactor: extract app route handler response helpers #716

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

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/619
Author: @southpolesteve
Created: 3/21/2026
Status: Merged
Merged: 3/21/2026
Merged by: @james-elicx

Base: mainHead: codex/app-route-handler-execution-runtime


📝 Commits (1)

  • 6b868ee refactor: extract app route handler response helpers

📊 Changes

5 files changed (+692 additions, -675 deletions)

View changed files

📝 packages/vinext/src/entries/app-rsc-entry.ts (+63 -96)
packages/vinext/src/server/app-route-handler-response.ts (+130 -0)
📝 tests/__snapshots__/entry-templates.test.ts.snap (+360 -576)
tests/app-route-handler-response.test.ts (+136 -0)
📝 tests/app-router.test.ts (+3 -3)

📄 Description

Summary

  • written by Codex
  • extract App Router route-handler response and cache-shaping helpers into a real typed server module
  • keep app-rsc-entry.ts focused on request orchestration while moving low-level Response assembly out of the template string
  • add direct unit coverage for the new route-handler response helper layer

What moved

  • middleware header/status application for route handlers
  • cached HIT/STALE response construction
  • APP_ROUTE cache-value serialization for ISR writes/regeneration
  • route-handler response finalization for pending cookies, draft mode cookies, and auto-HEAD body stripping

Files

  • new helper module: packages/vinext/src/server/app-route-handler-response.ts
  • new unit coverage: tests/app-route-handler-response.test.ts
  • generator wiring updated in packages/vinext/src/entries/app-rsc-entry.ts

Why this is the next step

#618 pulled direct request-access tracking out of the generated RSC entry.
This PR keeps going in the same hotspot, but takes the response/cache-shaping half next.
That leaves the generated route-handler block noticeably smaller and pushes more behavior into normal importable TypeScript.

Verification

  • vp check packages/vinext/src/server/app-route-handler-response.ts packages/vinext/src/entries/app-rsc-entry.ts tests/app-route-handler-response.test.ts tests/app-route-handler-runtime.test.ts tests/app-router.test.ts
  • vp test run tests/app-route-handler-response.test.ts tests/app-route-handler-runtime.test.ts
  • vp test run tests/entry-templates.test.ts -u
  • vp test run tests/app-router.test.ts -t "route handler"
  • vp test run tests/nextjs-compat/app-routes.test.ts
  • vp run vinext#build

Notes

  • This PR is stacked on #618 (codex/app-route-handler-runtime).
  • One generated-code assertion was updated to reflect the new helper-based APP_ROUTE cache write path instead of the old inline object literal.

🔄 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/619 **Author:** [@southpolesteve](https://github.com/southpolesteve) **Created:** 3/21/2026 **Status:** ✅ Merged **Merged:** 3/21/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `codex/app-route-handler-execution-runtime` --- ### 📝 Commits (1) - [`6b868ee`](https://github.com/cloudflare/vinext/commit/6b868eeecfbeba489c7919689737ee513e14b107) refactor: extract app route handler response helpers ### 📊 Changes **5 files changed** (+692 additions, -675 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+63 -96) ➕ `packages/vinext/src/server/app-route-handler-response.ts` (+130 -0) 📝 `tests/__snapshots__/entry-templates.test.ts.snap` (+360 -576) ➕ `tests/app-route-handler-response.test.ts` (+136 -0) 📝 `tests/app-router.test.ts` (+3 -3) </details> ### 📄 Description ## Summary - written by Codex - extract App Router route-handler response and cache-shaping helpers into a real typed server module - keep `app-rsc-entry.ts` focused on request orchestration while moving low-level `Response` assembly out of the template string - add direct unit coverage for the new route-handler response helper layer ## What moved - middleware header/status application for route handlers - cached HIT/STALE response construction - APP_ROUTE cache-value serialization for ISR writes/regeneration - route-handler response finalization for pending cookies, draft mode cookies, and auto-HEAD body stripping ## Files - new helper module: `packages/vinext/src/server/app-route-handler-response.ts` - new unit coverage: `tests/app-route-handler-response.test.ts` - generator wiring updated in `packages/vinext/src/entries/app-rsc-entry.ts` ## Why this is the next step `#618` pulled direct request-access tracking out of the generated RSC entry. This PR keeps going in the same hotspot, but takes the response/cache-shaping half next. That leaves the generated route-handler block noticeably smaller and pushes more behavior into normal importable TypeScript. ## Verification - `vp check packages/vinext/src/server/app-route-handler-response.ts packages/vinext/src/entries/app-rsc-entry.ts tests/app-route-handler-response.test.ts tests/app-route-handler-runtime.test.ts tests/app-router.test.ts` - `vp test run tests/app-route-handler-response.test.ts tests/app-route-handler-runtime.test.ts` - `vp test run tests/entry-templates.test.ts -u` - `vp test run tests/app-router.test.ts -t "route handler"` - `vp test run tests/nextjs-compat/app-routes.test.ts` - `vp run vinext#build` ## Notes - This PR is stacked on #618 (`codex/app-route-handler-runtime`). - One generated-code assertion was updated to reflect the new helper-based APP_ROUTE cache write path instead of the old inline object literal. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:09:46 +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#716
No description provided.