fix(dashboard): wrap each screen in its own ErrorBoundary - #623
Open
16navigabraham wants to merge 1 commit into
Open
fix(dashboard): wrap each screen in its own ErrorBoundary#62316navigabraham wants to merge 1 commit into
16navigabraham wants to merge 1 commit into
Conversation
A crash in one screen (e.g. TransactionHistory) previously tore down the entire Dashboard, including the Sidebar and TopBar, because only a single root-level ErrorBoundary existed in main.tsx. Each screen rendered by Dashboard now gets its own isolate-mode ErrorBoundary with a scoped fallback that names the crashed screen and offers a Retry button, which clears the boundary and re-mounts only that screen. The root ErrorBoundary in main.tsx is unchanged and still catches anything above Dashboard as a last resort. Closes Sorokit#564
|
@16navigabraham Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
Closes #564. Each screen rendered by
Dashboardnow has its ownErrorBoundary, so a crash in one screen no longer takes down the Sidebar, TopBar, or any other (hidden) screen.Problem
Dashboard.tsxhad noErrorBoundaryof its own — the only one in the app lived inmain.tsx, wrapping the entire<App />. A render error thrown by any single screen (e.g.TransactionsScreen→TransactionHistory) propagated all the way up and replaced the whole shell with the generic full-page fallback, discarding the sidebar, the active wallet/network context UI, and any state in the other screens thatDashboardnormally keeps mounted-but-hidden.What changed
src/screens/Dashboard.tsxvisitedmap is now wrapped in its own<ErrorBoundary isolate>, scoped to that screen's<div data-testid="screen-wrapper-...">— Sidebar, TopBar, and NetworkBanner render outside this boundary and are unaffected by a crash inside it.ScreenErrorFallbackcomponent (screen name + a "Retry" button) passed in as the boundary'sfallbackprop, so the fallback names the screen instead of showingErrorBoundary's generic "Something went wrong" copy.SCREEN_LABELSmaps eachNavSectionto its display name for the fallback (mirrors the existingPAGE_TITLESmap).ErrorBoundary.tsxitself or to the root boundary inmain.tsx—ErrorBoundary's existingreset()/resetKeymechanism already remounts only its own children, which is exactly what "Retry re-mounts only the affected screen" needs.src/screens/Dashboard.test.tsx— newdescribe("per-screen error boundaries (#564)")block (4 tests): a crashing screen doesn't take down the Sidebar/TopBar, the fallback shows the screen name and a Retry button, Retry recovers and re-mounts just that screen, and navigating to a different (working) screen is unaffected while the crashed one shows its fallback.Acceptance criteria
Testing
npx vitest run src/screens/Dashboard.test.tsx→ 15/15 pass (11 existing + 4 new).npm run typecheck→ clean.npm run build→ succeeds.Note for maintainers
While verifying this change I found this repo's
mainalready has some pre-existing, unrelated breakage independent of this PR:npm run lintcurrently fails onBatchPaymentProcessor.tsx,ClaimableBalanceCard.tsx, andSorokitProvider.tsx(react-hooks rule violations) and onsrc/lib/utils.test.ts;npm run test:exportsand the productionnpm run build's inline typecheck both fail on astring | nullvsstringmismatch inTransactionPanel.tsx:204; andnpm run sizefails to resolvedistimports. I confirmed all of these reproduce identically on a clean checkout ofmainviagit stash, so none of it is introduced by this PR — flagging in case it's useful, but intentionally out of scope here.