[PR #951] [MERGED] fix: serialize SSR render and head collection in Pages Router (#792) #976

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/951
Author: @Divkix
Created: 4/29/2026
Status: Merged
Merged: 4/29/2026
Merged by: @james-elicx

Base: mainHead: fix/792-styled-jsx-race


📝 Commits (1)

  • 46011bf fix: serialize SSR render and head collection in Pages Router (#792)

📊 Changes

2 files changed (+53 additions, -1 deletions)

View changed files

📝 packages/vinext/src/server/pages-page-response.ts (+7 -1)
📝 tests/pages-page-response.test.ts (+46 -0)

📄 Description

Fixes #792

Summary

  • Audited styled-jsx race condition: vinext does not call styledJsxInsertedHTML() (no styled-jsx style registry exists), so the specific Next.js bug does not apply
  • Fixed a related ordering bug in Pages Router prod path: getSSRHeadHTML() was called before renderToReadableStream(), causing <Head> content to be silently dropped from SSR HTML
  • Fixed clearSsrContext() ordering: SSR context was cleared before rendering, so useRouter() would return defaults during SSR
  • Verified dev-server.ts and app-ssr-entry.ts are already correct (render first, then collect styles)
  • Added ordering tests to verify render completes before style/context collection

Test plan

  • Added 2 unit tests in pages-page-response.test.ts that verify renderToReadableStream is called before getSSRHeadHTML and clearSsrContext
  • All existing pages-page-response tests (7 total) pass
  • All head tests (30) pass
  • pages-router.test.ts (196 tests) pass
  • Build, lint, format, typecheck all pass

🔄 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/951 **Author:** [@Divkix](https://github.com/Divkix) **Created:** 4/29/2026 **Status:** ✅ Merged **Merged:** 4/29/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/792-styled-jsx-race` --- ### 📝 Commits (1) - [`46011bf`](https://github.com/cloudflare/vinext/commit/46011bfc97788d8a34ae4f8158680486267563b2) fix: serialize SSR render and head collection in Pages Router (#792) ### 📊 Changes **2 files changed** (+53 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/server/pages-page-response.ts` (+7 -1) 📝 `tests/pages-page-response.test.ts` (+46 -0) </details> ### 📄 Description Fixes #792 ## Summary - Audited styled-jsx race condition: vinext does not call `styledJsxInsertedHTML()` (no styled-jsx style registry exists), so the specific Next.js bug does not apply - Fixed a related ordering bug in Pages Router prod path: `getSSRHeadHTML()` was called before `renderToReadableStream()`, causing `<Head>` content to be silently dropped from SSR HTML - Fixed `clearSsrContext()` ordering: SSR context was cleared before rendering, so `useRouter()` would return defaults during SSR - Verified dev-server.ts and app-ssr-entry.ts are already correct (render first, then collect styles) - Added ordering tests to verify render completes before style/context collection ## Test plan - Added 2 unit tests in `pages-page-response.test.ts` that verify `renderToReadableStream` is called before `getSSRHeadHTML` and `clearSsrContext` - All existing `pages-page-response` tests (7 total) pass - All `head` tests (30) pass - `pages-router.test.ts` (196 tests) pass - Build, lint, format, typecheck all pass --- <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:21 +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#976
No description provided.