-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
HMR is often not working at all #18217
Comments
I am also having this issue! Using 4.4.2 in a project I haven't touched in awhile, come back to it and HMR is not working at all. It's also having issues with "cannot find named export XXXX in file src/pages/xxx.js" when it's clearly there. |
I see circular imports when running
In the past, circular import was triggering full reload, but that seems relaxed in #15118 If I add a log during import, then it always shows up, but not the one inside hook (meaning there's no re-rendering), so this could be an issue/limitation of React plugin specifically. //// src/lite/views/Collection/DragAndDrop/useAnimationStyling.tsx
import { dndGridClass } from "./DragAndDropGrid";
console.log("[import]", Date.now(), dndGridClass); // this log shows up always
export function useAnimationStyling() {
console.log("[hook]", Date.now(), dndGridClass);
} I tried to reproduce the issue with 3 files https://github.com/hi-ogawa/reproductions/tree/main/vite-18217-hmr-circular-import-react and a same behavior seems to happen, but it's very rare. |
I have also been experiencing this for a while. The HMR in a Vue project is very inconsistent and a change usually breaks the app, requiring a full reload. |
if any of your dependency is built from virtual module, we might have this problem. see other discussion in #12912 |
For some reason I'm seeing this recently but only in Safari. No circular imports, it does hot reload (Safari console says it accepts), but for some reason no change. Likely unrelated to this, maybe even a new Safari bug, but just noting for anyone else if they see it too. |
Describe the bug
Hi, multiple members of the team I'm working in are suffering from Vite's HMR sometimes not working at all (not even full page reloads happen, the page just isn't updated). In some files in the codebase, it consistently never works.
We're using vite together with react. It's driving us crazy when it doesn't work, since we've gotten used to HMR always working, so when things don't behave as expected in the browser, we first think our code is at fault. We re-think approaches and add debug information, only to notice even that doesn't work. Then we reload the page, which unfortunately given our project size takes around 35 seconds (so it isn't a viable workaround to always reload). After a reload, our code suddenly works, and we get frustrated.
This led me to providing this reproduction, in hopes of someone knowing how to fix it. As copying files into a fresh repo didn't reproduce the bug, I have started out with the file where HMR never worked for us (
useAnimationStyling
) and spent hours painstakingly deleting files from our project.Unfortunately, the "hit rate" of the bug has gone down from 100% to ~15% in the process, yet the "minimal" reproduction contains 45 files. Most of them just contain one import and one export though.
Apparently, the bug has at least something to do with project size, as deleting a bunch of unused files (not imported at all from vite's entrypoint) from our actual repo seems to have decreased the success rate down to matching the one of the attached reproduction repo.
Please have some patience when trying to follow the reproduction steps.
Related issue: #16284 but I don't think this is the same since for us it works for some files all the time and never for some others.
Reproduction
https://github.com/danieltroger/vite-hmr-bug-repro
Steps to reproduce
git clone https://github.com/danieltroger/vite-hmr-bug-repro
cd vite-hmr-bug-repro
yarn
yarn dev
./src/lite/views/Collection/DragAndDrop/useAnimationStyling.tsx
in your editorCongratulations, you have hit the bug! When our project is in its full glory without any files deleted, this happens every time. You might have to do ~20 saves to hit it.
Here's a video of me walking through the reproduction steps (if it doesn't play, right click + save as and open it with QuickTime):
Screen.Recording.2024-09-27.at.16.56.46.mp4
System Info
The text was updated successfully, but these errors were encountered: