mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #354] [MERGED] fix: render global-error.tsx without root layout to avoid double <html> tags #504
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#504
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/354
Author: @NathanDrake2406
Created: 3/8/2026
Status: ✅ Merged
Merged: 3/8/2026
Merged by: @james-elicx
Base:
main← Head:fix/global-error-parity📝 Commits (1)
cf3e3a1fix: render global-error.tsx without root layout to avoid double <html> tags📊 Changes
2 files changed (+147 additions, -76 deletions)
View changed files
📝
packages/vinext/src/server/app-dev-server.ts(+94 -51)📝
tests/nextjs-compat/global-error.test.ts(+53 -25)📄 Description
Summary
<html>/<body>tags whenglobal-error.tsxrenders as the last-resort error boundary. It provides its own document shell (matching Next.js behavior), so wrapping it inside the root layout produced malformed HTML.tests/nextjs-compat/global-error.test.ts— previously only checkedstatus < 600andhtml.length > 0, now asserts HTTP 200, rendered content, and single<html>/<body>per response.Three changes to
app-dev-server.ts:buildPageElement: Removed global ErrorBoundary wrapping — it can't work for SSR because the root layout's HTML is already serialized in the RSC stream before the boundary activates, producing nested<html>tags.renderErrorBoundaryPage: Tracks_isGlobalErrorflag when error resolution falls through toglobal-error.tsx, and skips layout wrapping when it does.Next.js test reference
Ported from:
test/e2e/app-dir/global-error/basic/index.test.tsTest plan
pnpm test tests/nextjs-compat/global-error.test.ts— 7/7 passpnpm test tests/app-router.test.ts— 209/209 pass (no regressions)pnpm test tests/features.test.ts— 231/231 pass (no regressions)pnpm run typecheck— cleanpnpm run lint— 0 warnings, 0 errors🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.