Skip to content

fix(NewSite): prevent infinite reactivity loop from in-place sort mutation#6044

Open
ShuryaR wants to merge 1 commit intofrappe:developfrom
ShuryaR:fix/newsite-reactive-sort-develop
Open

fix(NewSite): prevent infinite reactivity loop from in-place sort mutation#6044
ShuryaR wants to merge 1 commit intofrappe:developfrom
ShuryaR:fix/newsite-reactive-sort-develop

Conversation

@ShuryaR
Copy link
Copy Markdown

@ShuryaR ShuryaR commented Apr 7, 2026

Summary

  • .sort() is called directly on reactive arrays inside computed properties (availableVersions, selectedVersionApps) and method (autoSelectVersion) in NewSite.vue
  • .sort() mutates the array in place, triggering Vue reactivity to re-evaluate dependents, which calls the same computed again — infinite loop freezing the browser
  • The bug is dormant with few marketplace apps (sort produces same order) but triggers when app count increases and sort reorders elements

Fix

Spread into a new array before sorting: [...arr].sort() instead of arr.sort()

Steps to Reproduce

  1. Publish 20+ marketplace apps with varying total_installs values
  2. Navigate to /dashboard/sites/new
  3. Browser tab freezes — "Loading..." stays forever, no JS error in console

Test Plan

  • /dashboard/sites/new loads without freezing with 20+ marketplace apps
  • Version selector shows all versions sorted correctly
  • App list shows apps sorted by installs
  • Full site creation flow works from /dashboard/sites/new
  • Site creation from /dashboard/groups/:bench/sites/new still works

…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.
@ShuryaR ShuryaR requested a review from siduck as a code owner April 7, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant