From b50e5c5c86e2c3fd597468222bd422bfc8ea2c26 Mon Sep 17 00:00:00 2001 From: Brenley Dueck Date: Thu, 23 Jul 2026 05:47:22 -0500 Subject: [PATCH] fix: send server environments their reload signal on hot update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Returning [] from hotUpdate for non-client environments suppresses the full-reload messages that would race client HMR, but it also suppresses the only signal environment-runner based servers (e.g. nitro's dev worker) have for re-evaluating modules: with the modules array emptied, Vite's dead-end propagation never fires the environment-level full-reload, so SSR keeps serving stale modules until the dev server is restarted — and hydration mismatches against the freshly HMR-updated client. Keep the suppression, but send the reload on the environment's own hot channel first. For runner-based environments that channel reaches the runner; for the default ssr environment it is a no-op; it is never the browser websocket, so client HMR stays free of full-reload races. --- src/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index d4f409c..5269173 100644 --- a/src/index.ts +++ b/src/index.ts @@ -626,12 +626,21 @@ export default function solidPlugin(options: Partial = {}): Plugin[] { } as typeof hot.send; }, - hotUpdate() { + hotUpdate({ modules }) { // solid-refresh only injects HMR boundaries into client modules, so // non-client environments have no accept handlers. Without this, Vite // would see no boundaries and send full-reload messages that race with // client-side HMR updates. if (this.environment.name !== 'client') { + // Returning [] also suppresses the signal environment-runner based + // servers (e.g. nitro's dev worker) rely on to re-evaluate modules, + // leaving SSR stale until a manual restart. Send the reload on this + // environment's own channel — for runner-based environments that is + // the runner, for the default ssr environment a no-op, and never the + // browser websocket, so client HMR stays free of full-reload races. + if (modules.length > 0) { + this.environment.hot.send({ type: 'full-reload' }); + } return []; } },