Fix Dashboard crash when navigating between routes with a Dashboard component#130
Merged
Merged
Conversation
Crashes the app with "Assertion Failed: You attempted to update <RelatedCollection:dashboard-widget>.length, but it had already been used previously in the same computation" whenever a user navigates between two routes that both mount a <Dashboard> component (e.g. host dashboard → a fleetops engine route with its own dashboard, or vice versa). Root cause: DashboardComponent's constructor runs DURING a render. The constructor synchronously calls dashboard.reset(), which since 098141a synchronously calls store.unloadAll('dashboard-widget') + store.unloadAll('dashboard'). The previous Dashboard render had already consumed `<RelatedCollection:dashboard-widget>.length` in that same tracking frame, so the unload's tag mutation violates Ember's "no mutate after consume in the same computation" rule and tears down rendering. Fix: schedule both the store unloads (inside reset()) and the loadDashboards.perform() call (in the component constructor) onto the next runloop tick via next(). They queue in registration order, so the unloads run first, then loadDashboards re-queries against a clean store — and crucially both happen AFTER the in-flight render finishes, keeping the tag mutation outside the consumed tracking frame. Co-Authored-By: Claude Opus 4.7 (1M context) <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
Hotfix for a regression introduced in #129 (v0.3.30). Navigating from one route that mounts
<Dashboard>to another route that also mounts<Dashboard>(e.g. host home → a fleetops engine route, or vice versa) crashes the app with:Root cause
DashboardComponent's constructor runs during a render. The constructor synchronously callsdashboard.reset(), which since #129 synchronously callsstore.unloadAll('dashboard-widget')+store.unloadAll('dashboard'). The previous Dashboard render had already consumed<RelatedCollection:dashboard-widget>.lengthin the same tracking frame, so the unload's tag mutation violates Ember's "no mutate after consume in the same computation" rule and tears down rendering.Fix
Schedule both the store unloads (inside
reset()) and theloadDashboards.perform()call (in the component constructor) onto the next runloop tick vianext(). They queue in registration order, so the unloads run first, thenloadDashboardsre-queries against a clean store — and crucially both happen after the in-flight render finishes, keeping the tag mutation outside the consumed tracking frame.The prior code had this pattern; #129 removed the
next()wrappers in a misguided "simplification." Restoring them with a comment explaining why they're load-bearing.Test plan
<Dashboard>at the host home route, navigate to a fleetops engine route that also mounts a<Dashboard>— no assertion fires, both render cleanly.<Dashboard>renders, no console errors.ember test).npm run lint).🤖 Generated with Claude Code