vite icon indicating copy to clipboard operation
vite copied to clipboard

HMR can't be disabled (hmr: false)

Open arpowers opened this issue 1 year ago • 2 comments

Describe the bug

I believe that HMR should be disabled if it is set as hmr: false and/or vite is running in production mode.

This is an issue in my case, as we'd like to just run the dev server for a testing site but we get these continual pings (noise)

here is the example site:Example Site

config has this:

const viteServer = await createServer({ 
      mode: "production",
      server: {
        middlewareMode: true,
        hmr: false,
      },
      appType: "custom",
       // other config
    })

Note that I've seen others comment about the lack of ability to turn off HMR elsewhere since the 3.0 release: example

Reproduction

https://example.kaption.co

System Info

Fly.io VM

Used Package Manager

pnpm

Logs

No response

Validations

arpowers avatar Jul 28 '22 17:07 arpowers

The websocket is used for more than HMR as explained at https://github.com/vitejs/vite/issues/6315#issuecomment-1166558944. Disabling it completely would disable the other features too. Maybe we can allow that, but it would be good if you're proxying the websocket server too.

bluwy avatar Jul 29 '22 08:07 bluwy

Thanks. As an idea, I think that with transpilation becoming less of a problem Vite could run SSR directly from the DevServer instead of the dual-build (very complicated) SSR method currently recommended.

We ran into a few small issues doing this (like the above) but it almost worked. Feels like a missed opportunity.

arpowers avatar Jul 30 '22 00:07 arpowers

I'll close this for now as it's working as intended.

bluwy avatar Aug 16 '22 16:08 bluwy