vitejs / vite

Next generation frontend tooling. It's fast!
http://vitejs.dev
MIT License
65.92k stars 5.88k forks source link

Not possible to cancel full reload via vite:beforeFullReload in 5.2.13 #17447

Open hiber-stefan opened 3 weeks ago

hiber-stefan commented 3 weeks ago

Describe the bug

We use vite for a react-like dev environment. Key for us is to be able to stop full reloads, as we manage reloads ourselves via custom plugins. Up until now, we have been able to cancel full reload with this:

     if (import.meta.hot) {
              import.meta.hot.on('vite:beforeFullReload', (payload) => {
                throw '(skipping full reload)';
              });

              import.meta.hot.accept(() => {
                console.info('Hot reload: updated ${path.basename(id)}');
                import.meta.hot.invalidate();
              });
          }

This has now stopped working; reverting back to 5.1.7 makes the use case work again.

We have inspected the event code in vite, but can see no obvious local current change that would explain this.

Reproduction

https://stackblitz.com/edit/vitejs-vite-kdguwf

Steps to reproduce

System Info

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M3
    Memory: 161.75 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.14.0 - ~/.nvm/versions/node/v20.14.0/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.7.0 - ~/.nvm/versions/node/v20.14.0/bin/npm
    pnpm: 8.15.8 - ~/.nvm/versions/node/v18.18.2/bin/pnpm
  Browsers:
    Chrome: 125.0.6422.144
    Safari: 17.5

Used Package Manager

npm

Logs

No response

Validations

stackblitz[bot] commented 3 weeks ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.