Repository navigation
fix: release previous exports after a hot update - #151
Merged
Merged
Conversation
Each module version kept the previous version's exports on `hot.data`, so every version of a refresh boundary stayed reachable for the life of the page. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Assert that `hot.data` is empty after an accepted update, an invalidated boundary and a module that stops being a boundary, and flush the refresh timer before the assertions. Reword the comment on the release. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Each hot update of a refresh boundary left the previous version's exports on the new version's
hot.data, so every version of the module, and everything it had imported, stayed reachable for the life of the page. Deletehot.data.prevExportsonce it has been read. The boundary comparison still runs against the previous exports, and a regression test covers the release on an accepted update, an invalidated boundary and a module that stops being a boundary.In the
exampleapp, I edited a large module imported byApp.tsxsix times. That left 7 live copies of the module before this change and 3 after: the current one in the module cache, plus the first and the previous one, which a heap snapshot shows are still referenced from React's fibers forApp.A boundary module that is removed from the module graph is never run again, so its last exports stay on the runtime's module data. That is one version per removed module, and this change does not affect it.
Related Links
Fixes #150