Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR Page Reload does not refresh page on the client after upgrading to Vite 6 #19114

Open
7 tasks done
rossrobino opened this issue Dec 31, 2024 · 5 comments
Open
7 tasks done

Comments

@rossrobino
Copy link

Describe the bug

Using the create-vite-extra - Vanilla SSR template, when editing src/entry-server.ts and saving, it no longer triggers a page reload. Editing and saving entry-client works as expected.

When using v5.4.9 this does not occur.

Reproduction

https://github.com/bluwy/create-vite-extra/tree/master/template-ssr-vanilla

Steps to reproduce

npm create vite-extra@latest (vanilla SSR)
npm i
npm run dev

edit src/entry-server.ts and save, I'm thinking this should trigger refresh

System Info

System:
    OS: macOS 15.1
    CPU: (8) arm64 Apple M1
    Memory: 163.77 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.5.1 - ~/.nvm/versions/node/v22.5.1/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v22.5.1/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v22.5.1/bin/npm
    pnpm: 9.11.0 - ~/.nvm/versions/node/v22.5.1/bin/pnpm
    bun: 1.1.30 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 131.0.6778.205
    Chrome Canary: 133.0.6929.0
    Safari: 18.1
    Safari Technology Preview: 18.2
  npmPackages:
    vite: 6.0.6 => 6.0.6

Used Package Manager

npm

Logs

No response

Validations

@hi-ogawa
Copy link
Collaborator

hi-ogawa commented Jan 2, 2025

This is a known breaking change and the doc has an example plugin to trigger the reload like before https://vite.dev/guide/migration.html#advanced

Updates to an SSR-only module no longer triggers a full page reload in the client. To return to the previous behaviour, a custom Vite plugin can be used:

@bluwy
Copy link
Member

bluwy commented Jan 2, 2025

Yeah I think this is expected, though I didn't know that it's also affecting our recommended SSR setup which SSR modules now appear to not have HMR working. We may need to update our docs to re-enable that, or if this leads to needing a new API 🤔

@bluwy bluwy added the feat: ssr label Jan 2, 2025
@rossrobino
Copy link
Author

Got it @hi-ogawa, this works and unblocks me!

@bluwy - In this case, is it really HMR when it's an SSR only module, doesn't it refresh the entire page?
FWIW, to me, it's confusing to have the logs say (ssr) page reload src/entry-server.ts when you save, but not have the page refresh.

Thank you both!

@bluwy
Copy link
Member

bluwy commented Jan 2, 2025

Yeah perhaps HMR isn't the right term here 😅 But updates not appearing on the screen is a bit problematic even if it's a full page reload. With the current setup, I don't know if it's possible or makes sense to make the updates fine-grained.

it's confusing to have the logs say (ssr) page reload src/entry-server.ts when you save

Maybe it should be "app reload" or "environment reload". It's causing a "full page reload" on the server-side modules, but there's no page on the server-side. It was likely borrowed when we refactor the HMR for the environment api.

@rossrobino
Copy link
Author

That makes sense, yeah I like "app/environment reload" I think that would be more clear.

Thanks for looking into this, let me know if I can help somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants