Destroy consumers of rejected duplicates, keep state updaters pure - #36
Merged
Conversation
Deploying sourcemap-tools with
|
| Latest commit: |
3284631
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5ccb458c.sourcemap-tools.pages.dev |
| Branch Preview URL: | https://fix-consumer-lifecycle.sourcemap-tools.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #36 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 9 9
Lines 203 208 +5
Branches 51 52 +1
=========================================
+ Hits 203 208 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Owner
Author
|
Added a follow-up commit that restores 100% coverage and enforces it via The three uncovered spots and how they were handled:
|
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.
Closes #23
Closes #24
What
Reworks
useSourcemapsStoreso thatSourceMapConsumerlifecycle management happens outside the React state updaters.destroy()ed instead of leaking on every re-upload of the same file. Duplicates within one file selection are also deduplicated now (previously two identical files picked together were both added).deleteSourceMapcalledtarget.consumer.destroy()inside thesetSourceMapsupdater. Updaters must be pure — StrictMode invokes them twice, callingdestroy()twice. The lookup anddestroy()now happen in the event handler; the updater only filters.Deliberately not destroying consumers on unmount: StrictMode's dev-only remount preserves state while running effect cleanups, so an unmount cleanup would destroy consumers that are still referenced after the remount. The store lives in the root component, where unmount means page unload anyway.
Tests
Three new integration tests in the
source map lifecyclesuite spy ondestroy()via the prototype of the concrete consumer class:StrictModedestroys the consumer exactly once.All three fail against the previous implementation and pass with the fix; the full suite is 29/29.