fix(NewSite): prevent infinite reactivity loop from in-place sort mutation#6044
Open
ShuryaR wants to merge 1 commit intofrappe:developfrom
Open
fix(NewSite): prevent infinite reactivity loop from in-place sort mutation#6044ShuryaR wants to merge 1 commit intofrappe:developfrom
ShuryaR wants to merge 1 commit intofrappe:developfrom
Conversation
…ation Computed properties `availableVersions`, `selectedVersionApps`, and method `autoSelectVersion` call `.sort()` directly on reactive arrays which mutates them in place, triggering Vue re-evaluation of dependents and causing an infinite loop that freezes the browser. The bug is dormant with few marketplace apps but triggers when app count increases enough for sort to produce a different order. Fix: spread into a new array before sorting to avoid mutating reactive source data.
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
.sort()is called directly on reactive arrays inside computed properties (availableVersions,selectedVersionApps) and method (autoSelectVersion) inNewSite.vue.sort()mutates the array in place, triggering Vue reactivity to re-evaluate dependents, which calls the same computed again — infinite loop freezing the browserFix
Spread into a new array before sorting:
[...arr].sort()instead ofarr.sort()Steps to Reproduce
total_installsvalues/dashboard/sites/newTest Plan
/dashboard/sites/newloads without freezing with 20+ marketplace apps/dashboard/sites/new/dashboard/groups/:bench/sites/newstill works