Skip to content

fix: wrap every route in error boundary with working try again reset - #586

Open
waterWang wants to merge 1 commit into
Protocol-Guild:mainfrom
waterWang:feat/error-boundary-routes
Open

fix: wrap every route in error boundary with working try again reset#586
waterWang wants to merge 1 commit into
Protocol-Guild:mainfrom
waterWang:feat/error-boundary-routes

Conversation

@waterWang

Copy link
Copy Markdown

Summary

Wraps every route in the app with an ErrorBoundary that provides a meaningful fallback UI and a working "Try Again" button. Route changes automatically recover from error states.

Changes

ErrorBoundary.tsx — New capabilities

  • onReset prop: Called when the boundary resets (e.g. user clicks "Try Again")
  • resetKeys prop: When keys change, the boundary auto-recovers — enables route-based recovery
  • "Try Again" wiring: The render method injects a real onReset handler into the fallback element when it doesn't already have one, so the "Try Again" button in ErrorFallback actually clears the error state
  • Console stack trace: componentDidCatch now logs console.error(...) with the error and component stack

App.tsx — Route boundary unification

  • New RouteBoundary component that uses useLocation().pathname as resetKeys — navigating away from a crashed route automatically recovers
  • Wraps every route (including /login and /auth-callback) in RouteBoundary
  • Simplifies pattern: removes the onReset={() => {}} no-op from all route fallbacks

main.tsx — Root boundary now uses real reset

  • Removed the onReset={() => {}} no-op from the root ErrorBoundary; the component now injects the real handler automatically

Acceptance Criteria

  • Every route wrapped in ErrorBoundary
  • Fallback shows error message and "Try Again" button
  • Error doesn't propagate to parent routes
  • Console shows component stack trace in dev mode

- Upgrade ErrorBoundary with onReset and resetKeys support, inject
  working 'Try Again' handler into fallback, log component stack trace
- Add RouteBoundary in App.tsx that auto-resets on route change
- Wrap /login and /auth-callback routes in ErrorBoundary
- Wire real onReset at the root boundary in main.tsx
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