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
[Fresh] Fix an infinite loop in an edge case #17414
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 9fe214a:
|
Details of bundled changes.Comparing: a7d07ff...9fe214a react-refresh
Size changes (stable) |
Details of bundled changes.Comparing: a7d07ff...9fe214a react-refresh
Size changes (experimental) |
// If we don't do this, there is a risk they will be mutated while | ||
// we iterate over them. For example, trying to recover a failed root | ||
// may cause another root to be added to the failed list -- an infinite loop. | ||
let failedRootsSnapshot = new Map(failedRoots); |
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.
is it supposed that new Map([iterable])
is polyfilled in react-refresh
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.
Would IE11 be the only one that can’t do it? I guess we could use something longer but tbh I don’t know if we care about supporting IE11 for a developer productivity feature like this.
Ouch, a classic bug. |
A good old mutation-while-iterating kind of bug. These maps and sets can be mutated during a commit, so we can't just
forEach
here. Otherwise we risk running into an infinite loop where processing each next item causes more items to be added to the list.Added a regression test. Verified this fixes a problem on WWW.