Skip to content

fix: reload the browser when the server entry or middleware changes in dev - #2255

Merged
brenelz merged 2 commits into
solidjs:mainfrom
birkskyum:fix-entry-server-hmr-issue
Oct 14, 2026
Merged

brenelz merged 2 commits into
solidjs:mainfrom
birkskyum:fix-entry-server-hmr-issue

Conversation

@birkskyum

@birkskyum birkskyum commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

Problem

entry-server.tsx and 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: editing src/entry-server.tsx in apps/fixtures/bare produces zero messages on the client HMR socket.

Fix

Adds a serverOnlyReload() plugin to devServer(). On hotUpdate for the ssr environment, if the changed file is the resolved server entry or the configured middleware, it sends a full-reload on 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 aliased middleware path 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 one full-reload for entry-server.tsx and for middleware.ts (in apps/fixtures/experiments), while editing src/app.tsx stays 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 the apps/tests Playwright suite (35 passed) are green.

@changeset-bot

changeset-bot Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0b13186

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/start Patch

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

@netlify

netlify Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for solid-start-landing-page ready!

Name Link
🔨 Latest commit 0b13186
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/6aceebef3eaeab313b4cd971
😎 Deploy Preview https://deploy-preview-2255--solid-start-landing-page.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/start@2255

commit: 0b13186

Comment thread packages/start/src/config/dev-server.ts
@lxsmnsyc

Copy link
Copy Markdown
Member

Doesn't the refresh reload pragma work

@birkskyum birkskyum closed this Jul 27, 2026
@lxsmnsyc lxsmnsyc reopened this Oct 14, 2026
@lxsmnsyc

Copy link
Copy Markdown
Member

Reopening. The // @refresh reload pragma does not cover this, so the fix is still needed.

Without this PR, on current main: apps/fixtures/bare's entry-server.tsx already starts with // @refresh reload. Editing it sends no HMR messages to the browser and the open page never reloads, with or without nitro(). Solid Refresh only acts on modules in the client graph, and entry-server is never in it.

With this PR merged onto current main (it merges cleanly, and the dev-server.spec.ts tests pass):

Edit HMR messages Page
bare: entry-server.tsx, with nitro() one full-reload reloads, edit visible
bare: entry-server.tsx, without nitro() one full-reload reloads, edit visible
experiments: middleware.ts one full-reload reloads
experiments: routes/index.tsx js-update only no reload, state kept

So it reloads only for the server-only entries and leaves normal HMR alone, as described. It is 48 commits behind main, so it needs a rebase before merging.

@brenelz
brenelz merged commit e0e6f6d into solidjs:main Oct 14, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: HMR for entry-server.tsx

3 participants