Menu

1 / 2

vite HMR is silently the reason ur laptop fan wont stop

DEV Community: vite·BaoDev Studio·5 months ago
#ujhwzpnf
#dev#vite#keeps#default#photo
Reading 0:00
15s threshold

ur working on a react app. ur fan kicks on. u assume chrome is the culprit, or slack, or the LSP. close tabs, kill apps, fan keeps spinning.

actual cause in 6 out of 10 projects i audit on macOS: vite's hot module replacement (HMR) doing way more work than needed. default config keeps websocket connections alive, polls file changes, rebuilds bundles aggressively. on a multi-monitor M-series macbook this lands as a consistent fan-on state even when ur not typing.

confirm its HMR first

quit ur dev server. wait 30 seconds. does the fan calm down?

yes → its HMR. no → look elsewhere (chrome tabs, docker, slack helper).

one-line fix

vite respects HMR env. flip it off when u dont need live reload:

HMR = off pnpm dev

Enter fullscreen mode

Exit fullscreen mode

or in vite.config.js :

export default defineConfig ({ server : { hmr : process . env . HMR !== ' off ' , }, });

Enter fullscreen mode

Exit fullscreen mode

with HMR off, vite still serves files but stops the websocket + file-watcher loop.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.