Vite · VITE0013

Dispose HMR side effects

Checks that Vite hmr code includes the dispose for side effects needed for predictable behavior.
VITE0013vite-doctor/vitehmrwarnNo fix
vite/hmr/require-dispose-for-side-effectssrc/rule-packs/vite/rules/plugin-hmr.ts Upstream docs

Run this rule

pnpm vite-doctor . --framework vite --rules vite/hmr/require-dispose-for-side-effects

Why it matters

Vite configuration runs in both dev and build pipelines. Narrow, explicit settings reduce surprises across SSR, workers, and local file access.

Add dispose for side effects where Vite expects it, close to the code that depends on it.

Example

Dispose HMR side effects

Before

const timer = setInterval(sync, 1000)

if (import.meta.hot) {
  import.meta.hot.accept()
}

After

const timer = setInterval(sync, 1000)

if (import.meta.hot) {
  import.meta.hot.dispose(() => clearInterval(timer))
}
Copyright © 2026