mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #491] [MERGED] fix: add headersSent guard in API route error handler #611
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#611
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/491
Author: @NathanDrake2406
Created: 3/12/2026
Status: ✅ Merged
Merged: 3/12/2026
Merged by: @james-elicx
Base:
main← Head:fix/api-handler-headers-sent-guard📝 Commits (3)
3d12fb9fix: add headersSent guard in API route error handlerffd0071fix: end response when headers already sent but stream not closed0192ebcchore: retrigger CI📊 Changes
1 file changed (+10 additions, -6 deletions)
View changed files
📝
packages/vinext/src/server/api-handler.ts(+10 -6)📄 Description
Summary
res.headersSentcheck in thehandleApiRoutecatch block before writing error responses (500/413)res.writeHead(200)) and then throws, the catch block would crash withERR_HTTP_HEADERS_SENT— now it silently skips the error response since the connection is already committedprod-server.ts:688andindex.ts:3518Test plan
pnpm test tests/pages-router.test.ts— 166/166 passingpnpm run fmt:check— clean🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.