feat: add Next.js route error boundaries and UI fallback - #1047
Merged
ayomideadeniran merged 1 commit intoAug 3, 2026
Conversation
|
@rhoggs-bot-test-account is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Devadakene 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! 🚀 |
Contributor
|
pr under review |
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.
Closes #884
Description
This PR introduces robust error handling mechanisms across the Next.js application shell and its key learning journeys. Previously, unexpected frontend exceptions could result in a blank screen or a completely broken state, leaving students stuck without clear recovery options.
By implementing Next.js route-level error boundaries, we intercept these exceptions and present users with a branded, accessible
ErrorFallbackUI. This interface provides explicit recovery actions, enabling students to either retry their current action without a full page reload or return safely to their dashboard.Implementation Details
1. Next.js Error Boundaries Added
Created standard Next.js
error.tsxboundary files to catch uncaught exceptions and prevent cascading UI failures across the application tree.src/app/error.tsx(catches global app-level errors)src/app/courses/error.tsxsrc/app/lessons/error.tsxsrc/app/simulator/error.tsxsrc/app/dashboard/error.tsx2. Enhanced UI Fallback & Recovery Options
Modified the shared
ErrorFallbackcomponent (src/components/ui/ErrorFallback.tsx) to support a more resilient user experience:onReturnHomeboolean prop to dynamically render a "Return to Dashboard" action link alongside the existing "Try again" (onRetry) button.3. Client-Safe Error Monitoring Integration
Integrated existing client-safe telemetry within the boundaries:
useGlobalStore((state) => state.setGlobalError).process.env.NODE_ENV === 'development') to help engineers debug easily without jeopardizing production security.4. Automated Component Testing
Added Vitest and React Testing Library tests in
src/components/ui/__tests__/ErrorFallback.test.tsxto prevent future regressions. The test suite covers:onRetrycallbacks when the "Try again" button is clicked.productionand visible indevelopment.Acceptance Criteria Met
How to Test Manually
fix/error-boundariesbranch and start the local development server./courses,/simulator, or/dashboardand manually throw a JavaScript error within a client component or page layout.ErrorFallbackUI render instead of a blank screen./dashboard.