fix: resolve current entry for dev HMR re-fetch in multi-entry mode#157
Merged
Conversation
In dev, server-code changes trigger an RSC re-fetch from the client, but the server handler always rendered the first entry, replacing the current page's content with the first entry's tree when viewing any other page (which affects every fs-routes app). The client now sends the current page path as a query parameter, and the server resolves it with findEntryForUrlPath plus the same SPA fallback as serveHTML. Closes #140 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VfH2tK77WCGbfh24sU4yRp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In dev, server-code changes trigger
rsc:updateand the client re-fetches the RSC payload fromdevMainRscPath. The server handler (serveRSC) always renderedentries[0], so with multiple entries, editing server code while viewing any non-first page replaced the page content with the first entry's tree. This affected every fs-routes app, since fs-routes produces one entry per page.Fix
src/client/entry.tsx): the HMR re-fetch now includes the current page path as apathquery parameter.src/rsc/entry.tsx):serveRSCresolves that path with the existingfindEntryForUrlPathplus the same SPA fallback asserveHTML(extracted into a sharedresolveEntryForUrlPathhelper). If nopathparameter is provided, it falls back to the first entry as before.Tests
Added an e2e test in
e2e/tests-dev/multi-entry.spec.tsthat loads a non-first entry, edits its server component on disk, and asserts the updated content appears via HMR while the page still shows its own tree (not the first entry's). The multi-entry fixture gained a dedicatedhmr-test.htmlentry so the test's file edits can't interfere with parallel tests.Verified the test fails against the old behavior and passes with the fix. Build, typecheck, lint, unit tests, and all dev + production e2e suites pass.
Closes #140
🤖 Generated with Claude Code
https://claude.ai/code/session_01VfH2tK77WCGbfh24sU4yRp
Generated by Claude Code