-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
fix(hmr): Fix circular dep root starts hmr, and has invalidate in it,… #11268
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).