Vite · HMR

VITE0013Dispose HMR side effects

Checks that Vite hmr code includes the dispose for side effects needed for predictable behavior.

Why it happens

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

Fix

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))
}

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

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