fix: reload the browser when the server entry or middleware changes in dev - #2255
Closed
birkskyum wants to merge 1 commit into
Closed
fix: reload the browser when the server entry or middleware changes in dev#2255birkskyum wants to merge 1 commit into
birkskyum wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 299566c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for solid-start-landing-page ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
commit: |
brenelz
reviewed
Jul 27, 2026
| export function devServer(serverEntryPath: string): Array<PluginOption> { | ||
| export function devServer(serverEntryPath: string, middlewarePath?: string): Array<PluginOption> { | ||
| return [ | ||
| serverOnlyReload(serverEntryPath, middlewarePath), |
Contributor
There was a problem hiding this comment.
probably good if someone else reviews this but overall looks good
Member
|
Doesn't the refresh reload pragma work |
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.
entry-server.tsx#1611Problem
entry-server.tsxand the configured middleware are server-only, so they have no module in the client graph and Vite has nothing to send the browser when they change. The dev server re-imports the server entry per request, so the edit is live on the next request, but the open page keeps showing the shell rendered from the previous version until you refresh by hand. Reproduced on the current RC: editingsrc/entry-server.tsxinapps/fixtures/bareproduces zero messages on the client HMR socket.Fix
Adds a
serverOnlyReload()plugin todevServer(). OnhotUpdatefor thessrenvironment, if the changed file is the resolved server entry or the configured middleware, it sends afull-reloadon the client hot channel (debounced so one save touching both only reloads once). Both paths are resolved through the ssr environment's plugin container, so an extensionless or aliasedmiddlewarepath still matches.Only those two entries are handled: modules that also exist on the client (routes, components, server functions) are left to Vite, since reloading on top of a client HMR update would needlessly throw away the page's state. This is also why the check is not the broader "file has no module in the client graph" rule, which would reload and reset the current page whenever you edit a lazy route you have not navigated to yet.
Verification
Browser check on
apps/fixtures/bare: before the change the page never updates and needs a manual refresh; after it, the edit appears on its own and the hydrated counter resets, confirming a real reload. An HMR socket probe shows exactly onefull-reloadforentry-server.tsxand formiddleware.ts(inapps/fixtures/experiments), while editingsrc/app.tsxstays silent as before. New unit tests cover both entries plus the cases that must stay silent.tsc --noEmit,vitest run(77 passed),oxfmt --check, and theapps/testsPlaywright suite (35 passed) are green.