mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[GH-ISSUE #962] Route-level boundary nesting order diverges from Next.js #208
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#208
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?
Originally created by @Divkix on GitHub (Apr 29, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/962
Identified during review of #945.
Context
At the route level in
app-page-route-wiring.tsx(around line 567-604), the ErrorBoundary sits inside the access fallback boundaries (NotFoundBoundary, ForbiddenBoundary, UnauthorizedBoundary). In Next.js, ErrorBoundary is always outermost.This was already wrong for NotFoundBoundary before PR #945, but adding ForbiddenBoundary and UnauthorizedBoundary outside ErrorBoundary amplifies the divergence.
Current nesting (vinext, wrong)
Expected nesting (Next.js)
Suggested approach
Reorder the boundary wrapping in
wrapRouteChildreninapp-page-route-wiring.tsxso that ErrorBoundary wraps the access fallback boundaries.@Divkix commented on GitHub (Apr 29, 2026):
Root Cause
In
packages/vinext/src/server/app-page-route-wiring.tsxlines 555–571, the route-level boundary wrapping builds the wrong nesting order. ErrorBoundary is applied first (line 561), then NotFoundBoundary wraps it (line 569). This produces:Expected Behavior (Next.js)
Next.js's
create-component-tree.tsxhas an explicit comment at line 579:Building bottom-up (innermost first), the correct order is:
What to Fix
In
app-page-route-wiring.tsx, swap the order of the twoifblocks so NotFoundBoundary is applied first, then ErrorBoundary wraps it:NotFoundBoundaryblock (lines 582–591) wraps beforeErrorBoundary(lines 593–598), so they need swapping there tooNext.js Reference
packages/next/src/server/app-render/create-component-tree.tsxline 136 — importsHTTPAccessFallbackBoundarywhich houses NotFound/Forbidden/Unauthorized. The segment-level nesting at lines 1065–1090 showsHTTPAccessFallbackBoundarywrapping innerclientSegment, withErrorBoundaryat the level above. Error is always outermost relative to NotFound.