[PR #784] [MERGED] fix: move NotFoundBoundary inside Template in per-segment wiring #844

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

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/784
Author: @NathanDrake2406
Created: 4/5/2026
Status: Merged
Merged: 4/5/2026
Merged by: @james-elicx

Base: mainHead: fix/notfound-inside-template


📝 Commits (2)

  • 20519bb test: assert not-found fallback renders inside template
  • 88c0e29 fix: move NotFoundBoundary inside Template in per-segment wiring

📊 Changes

2 files changed (+103 additions, -10 deletions)

View changed files

📝 packages/vinext/src/server/app-page-route-wiring.tsx (+11 -10)
📝 tests/app-page-route-wiring.test.ts (+92 -0)

📄 Description

Summary

  • NotFoundBoundary was placed outside Template in the per-segment layout loop, producing Layout > NotFound > Template > Error > Page
  • Next.js wraps NotFound inside Template via TemplateContext — the correct order is Layout > Template > Error > NotFound > Page
  • When notFound() fired, the NotFound fallback replaced the entire Template subtree instead of rendering inside it

Moves the layoutNotFoundComponent wrapping to the top of the loop body (before ErrorBoundary), making it the innermost wrapper. Since the loop builds bottom-up, this produces the correct outer-to-inner nesting.

This is a pre-existing bug surfaced by the comment introduced in #780.

Test plan

  • New structural test (NotFoundBoundary is nested inside Template) walks the React element tree and asserts RootTemplate appears at a shallower depth than NotFoundBoundaryInner
  • Test failed before fix (NotFoundBoundary was depth 2, RootTemplate depth 3 — inverted)
  • All 10 tests in tests/app-page-route-wiring.test.ts pass after fix
  • vp check passes with no type errors

🔄 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/784 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 4/5/2026 **Status:** ✅ Merged **Merged:** 4/5/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/notfound-inside-template` --- ### 📝 Commits (2) - [`20519bb`](https://github.com/cloudflare/vinext/commit/20519bb87d5555bb29943c654cf2473073ac2f25) test: assert not-found fallback renders inside template - [`88c0e29`](https://github.com/cloudflare/vinext/commit/88c0e291a042c099e685d5ed07ab8b3343939d54) fix: move NotFoundBoundary inside Template in per-segment wiring ### 📊 Changes **2 files changed** (+103 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/server/app-page-route-wiring.tsx` (+11 -10) 📝 `tests/app-page-route-wiring.test.ts` (+92 -0) </details> ### 📄 Description ## Summary - `NotFoundBoundary` was placed **outside** `Template` in the per-segment layout loop, producing `Layout > NotFound > Template > Error > Page` - Next.js wraps NotFound *inside* Template via `TemplateContext` — the correct order is `Layout > Template > Error > NotFound > Page` - When `notFound()` fired, the NotFound fallback replaced the entire Template subtree instead of rendering inside it Moves the `layoutNotFoundComponent` wrapping to the top of the loop body (before `ErrorBoundary`), making it the innermost wrapper. Since the loop builds bottom-up, this produces the correct outer-to-inner nesting. This is a pre-existing bug surfaced by the comment introduced in #780. ## Test plan - [ ] New structural test (`NotFoundBoundary is nested inside Template`) walks the React element tree and asserts `RootTemplate` appears at a shallower depth than `NotFoundBoundaryInner` - [ ] Test failed before fix (NotFoundBoundary was depth 2, RootTemplate depth 3 — inverted) - [ ] All 10 tests in `tests/app-page-route-wiring.test.ts` pass after fix - [ ] `vp check` passes with no type errors --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:10:25 +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#844
No description provided.