[PR #481] [MERGED] fix: add headersSent guard to Pages Router prod error handler #603

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

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/481
Author: @NathanDrake2406
Created: 3/12/2026
Status: Merged
Merged: 3/12/2026
Merged by: @james-elicx

Base: mainHead: fix/pages-router-headers-sent-guard


📝 Commits (1)

  • 4589c66 fix: add headersSent guard to Pages Router prod error handler

📊 Changes

1 file changed (+4 additions, -2 deletions)

View changed files

📝 packages/vinext/src/server/prod-server.ts (+4 -2)

📄 Description

Summary

  • Adds res.headersSent guard to the Pages Router production server error handler in prod-server.ts
  • If SSR begins streaming then throws, res.writeHead(500) was called on an already-sent response, causing a silent socket error
  • The App Router error handler (line 688) already has this guard — this brings the Pages Router path into parity

Test plan

  • CI passes (format, lint, typecheck, vitest, playwright)
  • Verify Pages Router prod server handles mid-stream SSR errors gracefully without socket crash

🔄 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/481 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 3/12/2026 **Status:** ✅ Merged **Merged:** 3/12/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/pages-router-headers-sent-guard` --- ### 📝 Commits (1) - [`4589c66`](https://github.com/cloudflare/vinext/commit/4589c66c33bb6034be2729eb023165d8205859fd) fix: add headersSent guard to Pages Router prod error handler ### 📊 Changes **1 file changed** (+4 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/server/prod-server.ts` (+4 -2) </details> ### 📄 Description ## Summary - Adds `res.headersSent` guard to the Pages Router production server error handler in `prod-server.ts` - If SSR begins streaming then throws, `res.writeHead(500)` was called on an already-sent response, causing a silent socket error - The App Router error handler (line 688) already has this guard — this brings the Pages Router path into parity ## Test plan - [x] CI passes (format, lint, typecheck, vitest, playwright) - [x] Verify Pages Router prod server handles mid-stream SSR errors gracefully without socket crash --- <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:01 +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#603
No description provided.