Skip to content

Commit 62d9a89

Browse files
authored
fix: send server environments their reload signal on hot update (#282)
1 parent c72cc55 commit 62d9a89

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'vite-plugin-solid': patch
3+
---
4+
5+
Send non-client server environments their own full-reload signal during hot
6+
updates. Environment-runner based servers now re-evaluate changed modules
7+
instead of serving stale SSR output, while client HMR remains unaffected.

src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,12 +656,21 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin[] {
656656
} as typeof hot.send;
657657
},
658658

659-
hotUpdate() {
659+
hotUpdate({ modules }) {
660660
// solid-refresh only injects HMR boundaries into client modules, so
661661
// non-client environments have no accept handlers. Without this, Vite
662662
// would see no boundaries and send full-reload messages that race with
663663
// client-side HMR updates.
664664
if (this.environment.name !== 'client') {
665+
// Returning [] also suppresses the signal environment-runner based
666+
// servers (e.g. nitro's dev worker) rely on to re-evaluate modules,
667+
// leaving SSR stale until a manual restart. Send the reload on this
668+
// environment's own channel — for runner-based environments that is
669+
// the runner, for the default ssr environment a no-op, and never the
670+
// browser websocket, so client HMR stays free of full-reload races.
671+
if (modules.length > 0) {
672+
this.environment.hot.send({ type: 'full-reload' });
673+
}
665674
return [];
666675
}
667676
},

0 commit comments

Comments
 (0)