fix(hmr): Fix circular dep root starts hmr, and has invalidate in it,…#11268
fix(hmr): Fix circular dep root starts hmr, and has invalidate in it,…#11268JSerFeng wants to merge 2 commits intovitejs:mainfrom
Conversation
… causing infinit hmr
|
@JSerFeng would you add a test case in the HMR playground for this issue? |
Done |
| import { value } from './child' | ||
|
|
||
| if (import.meta.hot) { | ||
| import.meta.hot.accept() |
There was a problem hiding this comment.
This PR does not work when this import.meta.hot.accept() is:
import.meta.hot.accept(() => {
import.meta.hot.invalidate()
})I guess we need to concatenate the previous chain (that called import.meta.invalidate) to the current chain (that happened by the import.meta.invalidate call).
|
hi, bro. I'm running into a similar problem right now |
|
Sorry, I'm busy in my school lately, and I don't have time to follow up currently, help wanted, or I'll continue some days later |
|
Since the PR has gone a bit stale, I'll close this for now and track in this new issue #16709. That way it's easier to track if anyone would like to contribute a fix. |
Infinite HMR caused by circular dep and
hot.invalidate()Description
Image a module A has dep B, and B also has dep A, if B has
hot.invalidate()in it, and B triggershmr, then it obviously will sendvite:invalidateto the server, then B's importers all starts to propagate this update, and B's importer is A, which has B as its dependency again. So it will cause infinite loop.How to reprod
mainanddep,mainimport some stuff fromdep, anddepalso import some stuff frommain, addimport.meta.hot.accept(() => { import.meta.hot.invalidate() })to thedep.main.tsfileAdditional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).