[PR #1026] [MERGED] fix(hmr): await router state readiness before rsc:update dispatch #1030

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

📋 Pull Request Information

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

Base: mainHead: fix/hmr-router-state-race


📝 Commits (3)

  • bee2ab4 fix(hmr): await router state readiness before rsc:update dispatch
  • 888897b fix(hmr): re-check browserRouterStateRef after readiness await
  • 5ba2a1d fix(hmr): re-check setter after createPendingNavigationCommit await

📊 Changes

1 file changed (+18 additions, -0 deletions)

View changed files

📝 packages/vinext/src/server/app-browser-entry.ts (+18 -0)

📄 Description

Summary

  • The rsc:update HMR handler in app-browser-entry.ts called getBrowserRouterState() directly, which throws when browserRouterStateRef is null.
  • browserRouterStateRef is only published inside BrowserRoot's layout effect, so an HMR event that fires while the initial RSC stream is still suspended (or after the tree has been torn down by an error) produces a noisy console error: [vinext] RSC HMR error: Error: [vinext] Browser router state is not initialized.
  • Await waitForBrowserRouterStateReady() at the top of the handler, mirroring the pattern already used by __VINEXT_RSC_NAVIGATE__.

Test plan

  • Trigger HMR (save a server file) while the initial RSC stream is still in flight — confirm the console error no longer appears.
  • Normal HMR after the page has hydrated still applies updates as before.

🤖 Generated with Claude Code


🔄 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/1026 **Author:** [@james-elicx](https://github.com/james-elicx) **Created:** 5/2/2026 **Status:** ✅ Merged **Merged:** 5/2/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/hmr-router-state-race` --- ### 📝 Commits (3) - [`bee2ab4`](https://github.com/cloudflare/vinext/commit/bee2ab49431db33bf30330bd8f5be8dc3c5ef28d) fix(hmr): await router state readiness before rsc:update dispatch - [`888897b`](https://github.com/cloudflare/vinext/commit/888897b0919435a13b5a8d4ece11ee2e6c473023) fix(hmr): re-check browserRouterStateRef after readiness await - [`5ba2a1d`](https://github.com/cloudflare/vinext/commit/5ba2a1d3a38a633c834cf0ad3e8062369d03c7cc) fix(hmr): re-check setter after createPendingNavigationCommit await ### 📊 Changes **1 file changed** (+18 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/server/app-browser-entry.ts` (+18 -0) </details> ### 📄 Description ## Summary - The `rsc:update` HMR handler in `app-browser-entry.ts` called `getBrowserRouterState()` directly, which throws when `browserRouterStateRef` is null. - `browserRouterStateRef` is only published inside `BrowserRoot`'s layout effect, so an HMR event that fires while the initial RSC stream is still suspended (or after the tree has been torn down by an error) produces a noisy console error: `[vinext] RSC HMR error: Error: [vinext] Browser router state is not initialized`. - Await `waitForBrowserRouterStateReady()` at the top of the handler, mirroring the pattern already used by `__VINEXT_RSC_NAVIGATE__`. ## Test plan - [ ] Trigger HMR (save a server file) while the initial RSC stream is still in flight — confirm the console error no longer appears. - [ ] Normal HMR after the page has hydrated still applies updates as before. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:11:39 +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#1030
No description provided.