Repository navigation
fix: reload the browser when the server entry or middleware changes in dev - #2255
Conversation
🦋 Changeset detectedLatest commit: 0b13186 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: |
|
Doesn't the refresh reload pragma work |
|
Reopening. The Without this PR, on current With this PR merged onto current
So it reloads only for the server-only entries and leaves normal HMR alone, as described. It is 48 commits behind |
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.