-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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 duplicated modules because of query params mismatch #2255
Comments
I've tested this with Vite 2.8.6 and can still reproduce the issue. |
Or maybe not the same issue, but really similar - sometimes HMR somehow mess with modules, so it ends with error (in my case it's TDZ error - |
I'm also getting |
That's not specific for Vue, I have just regular react project |
Yep, that's definitely caused by changing the file while hmr in process. Some race conditions, I think. |
So, basically, I get big-enough project, then:
I think there is even falling test for it at https://github.com/vitejs/vite/blob/main/playground/ssr-vue/__tests__/ssr-vue.spec.ts#L166 |
@Amareis would you create a new issue with a minimal reproduction against latest? |
I cannot, really, this is somehow based on big and complicated module graph I think. But reproducing just stable - change file, change file again while rebuild in progress and voila, module graph is broken - some importers imports older version and some - newer. Actual content of both versions is same, of course, it's only different timestamps in urls. |
I think for such cases we really needed tool to anonimize big projects -_- Just keep file structures and imports/exports. I'll try to do something similar now. |
Okay, there is my (anonimized) project: https://github.com/Amareis/vite-bug-example I edit file src/reviews/short-review. As I notice, react plugin make it much easier to create such error. I think it's because of slower transpilation times - but in rare cases such error can be caused even without it. |
@patak-dev if you can dig it down, it will be just nice - it's pretty damn annoing error, even if it's not breaking dev flow completely. |
@Amareis please create a new issue with this information linking to this one, so this is properly tracked and all collaborators are aware of it. Thanks! |
@patak-dev done! #10118 |
我只能希望我正确地遵循了中文说明
Describe the bug
HMR sometimes reload the same version of a given module with different query parameters, resulting in duplicated copies of this module in the browser. Different importers get different runtime copies of the same module, which will cause trouble if the duplicated module is stateful.
Here, the module
a.js
at 1614293358773 is incorrectly duplicated:I believe I also witnessed a situation in casual usage where both params were present, but not in the same order (
?t=...&import
and?import&t...
), resulting in a similar problem. But I don't have a reproduction for this one.Why is this
import
query param needed, by the way?Reproduction
https://github.com/rixo/esm-hmr-spec
The failing test is this one: importing-reloaded.spec.js. The failing assertion is here.
Run the failing test with:
yarn test --vite --filter reloaded
In order to open the Playwright browser and keep it open, to be able to inspect the network tab after the test has completed, run it with:
yarn test --vite --filter reloaded --open --keep
(I also recommend
yarn test --vite --filter reloaded --inspect-brk
, if you ever need to put a breakpoint in the Node code.)System Info
vite
version: 2.0.3The text was updated successfully, but these errors were encountered: