mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #324] [MERGED] fix: suppress Invalid hook call warning during layout pre-render probe #480
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#480
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/324
Author: @james-elicx
Created: 3/7/2026
Status: ✅ Merged
Merged: 3/7/2026
Merged by: @james-elicx
Base:
main← Head:fix/suppress-invalid-hook-call-in-layout-prerender📝 Commits (2)
57770ddfix: suppress Invalid hook call warning during layout pre-render probe8548735refactor: use AsyncLocalStorage to scope hook-warning suppression per-request📊 Changes
1 file changed (+90 additions, -70 deletions)
View changed files
📝
packages/vinext/src/server/app-dev-server.ts(+90 -70)📄 Description
Summary
redirect()/notFound()throws) was missing theconsole.errorsuppression that the page pre-render loop already haduse(promise)trigger React's dev-moderesolveDispatcher()check —H === nulloutsideperformWork()— producing noisystderrwarnings in tests even though the renders succeedtry/finallythat silences the expected warning, matching the existing suppression on the page probeRoot Cause
app-dev-server.tsprobes each layout component by callingLayoutComp({ params, children: null })outside React's render cycle. When a layout callsuse(getData()), React'sresolveDispatcher()findsH === null(the dispatcher is only set insideperformWork()) and emits the "Invalid hook call" warning. The page pre-render already suppressed this, but the layout pre-render did not.Testing
tests/nextjs-compat/app-rendering.test.ts— all 6 active tests pass with noInvalid hook calloutput onstderr.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.