mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #1078] [MERGED] refactor(server): dedupe action/page/route-handler error response building #1075
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#1075
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/1078
Author: @james-elicx
Created: 5/5/2026
Status: ✅ Merged
Merged: 5/5/2026
Merged by: @james-elicx
Base:
main← Head:refactor/dedupe-action-error-handling📝 Commits (1)
aef08eerefactor(server): dedupe action/page/route-handler error response building📊 Changes
4 files changed (+121 additions, -52 deletions)
View changed files
📝
packages/vinext/src/server/app-page-execution.ts(+8 -6)📝
packages/vinext/src/server/app-route-handler-policy.ts(+8 -7)📝
packages/vinext/src/server/app-server-action-execution.ts(+30 -39)➕
packages/vinext/src/server/next-error-digest.ts(+75 -0)📄 Description
Summary
new Response(\"Payload Too Large\", { status: 413 })calls inapp-server-action-execution.tsinto a localpayloadTooLargeResponse()helper.error.digestparsers into a new shared modulepackages/vinext/src/server/next-error-digest.tsexposinggetNextErrorDigest,parseNextRedirectDigest, andparseNextHttpErrorDigest.Follow-up to #1058.
Files changed
packages/vinext/src/server/next-error-digest.ts(new) — shared digest parsing helpers.packages/vinext/src/server/app-server-action-execution.ts— uses the new helpers ingetActionControlResponse,getActionRedirect, andisActionHttpFallback; replaces 4× inline 413 responses with a localpayloadTooLargeResponse()(only used in this file).packages/vinext/src/server/app-page-execution.ts—resolveAppPageSpecialErrornow uses the shared parsers.packages/vinext/src/server/app-route-handler-policy.ts—resolveAppRouteHandlerSpecialErrornow uses the shared parsers.Preserved per-call-site behaviour
The shared parsers return only the raw shape (
{ type, url, status }for redirects,{ status }for HTTP error fallbacks). Each caller still owns its own post-processing:app-server-action-execution.tskeeps theNumber.isInteger(statusCode)guard for HTTP error digests ingetActionControlResponse.app-server-action-execution.tsgetActionRedirectkeeps the full{ status, type, url }shape (only this site uses the redirecttype).app-route-handler-policy.tskeepsnew URL(redirectUrl, requestUrl).toString()resolution and theisAction ? 303 : redirect.statusoverride.app-page-execution.tskeeps the basePath-and-cookie merging at the call site.Minor unification
parseNextRedirectDigestreturnsnullwhen the encoded URL segment is missing — matching the existing guard inapp-server-action-execution.ts. The page and route-handler call sites previously would have thrownURIErrorfromdecodeURIComponent(undefined)for a malformedNEXT_REDIRECT;digest with no URL; they now treat it as not-a-redirect and let the error propagate. This case is unreachable for any digest Next.js actually emits.Test plan
pnpm vp test run tests/app-router.test.ts— 308 tests passpnpm fmt --writeon touched files — cleanpnpm knip— cleantsc --noEmiton the vinext package — clean🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.