#531 Add resilient global error boundaries and route-level diagnostic… - #540
Merged
Conversation
…-level diagnostics FIXED
Contributor
Author
|
PLEASE @MaryammAli ... When you have a chance to review and approve the PR, please issue the payment through GrantFox. Receiving the payment for this milestone will help me keep pushing forward and stay motivated on future contributions. Thanks, |
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 & Overview
This PR hardens the frontend application against route-level errors, unexpected React component tree crashes, unhandled asynchronous fetch failures, and local storage corruption. It introduces accessible fallback UI states with clear recovery actions (in-place retry, reload, and safe home route navigation), comprehensive secret and PII scrubbing before telemetry dispatch, and route-level error boundaries for Next.js App Router.
🚩 Problem & Motivation
marketplaceApi.fetchListings()), the UI remained stuck indefinitely in skeleton loading state with no error banner or retry button.S...), Bearer tokens, JWTs, API keys, passwords, and sensitive object keys exposed in crash reports.localStoragecaused runtime exceptions during notification hydration.analyticsApiswallowed errors silently without triage reporting.🚀 Key Changes
1. Route-Level & Application Error Boundaries
app/frontend/src/app/error.tsx: Added Next.js App Router route segment error boundary with automatic error capture and "Try again" / "Return to Home" recovery options.app/frontend/src/app/global-error.tsx: Added root layout error boundary to catch critical root-level failures.app/frontend/src/components/ErrorBoundary.tsx:static getDerivedStateFromErrorfor immediate error-state transitions.fallback(ReactNode or render function(error, retry) => ReactNode) andonErrorcallback.role="alert",aria-live="assertive") with retry, home navigation, and issue reporting actions.2. Global Error Shell & Telemetry Hardening
app/frontend/src/components/ErrorReportingShell.tsx: Registered global listeners forwindow.onerrorandwindow.unhandledrejectionwith origin metadata and unmount cleanup.app/frontend/src/lib/errorReporter.ts(redactPII&extractCodeOrigin):S[A-Z0-9]{55}), Bearer tokens, JWT tokens, API keys, passwords, and secrets.password,secret,apiKey,token,secretKey,auth,authorization).codeOriginextraction from stack traces and context.window.location.pathname) when omitted.3. Async Fetch Resilience & Page Recovery Paths
app/frontend/src/app/marketplace/page.tsx: Replaced infinite loading on fetch failures with anerrorstate, fallback UI, retry buttons, and defensive checks for real-time bid updates.app/frontend/src/app/settings/page.tsx: Added error telemetry for profile load/save failures, an interactive retry banner, and broken avatar image fallbacks.app/frontend/src/hooks/analyticsApi.ts: IntegratederrorReporter.captureErrorinfetchAnalyticsandexportAnalyticsReport.app/frontend/src/components/NotificationCenterProvider.tsx: AddedArray.isArrayguards for corrupt localStorage values and captured deserialization failures toerrorReporter.📂 File Changes Breakdown
Modified Files (12)
app/frontend/src/lib/errorReporter.tsapp/frontend/src/components/ErrorBoundary.tsxgetDerivedStateFromError, recovery actionsapp/frontend/src/components/ErrorReportingShell.tsxapp/frontend/src/app/layout.tsxapp/frontend/src/app/page.tsxapp/frontend/src/hooks/analyticsApi.tsapp/frontend/src/app/marketplace/page.tsxapp/frontend/src/app/settings/page.tsxapp/frontend/src/components/NotificationCenterProvider.tsxapp/frontend/src/app/pay/PaymentPageClient.tsxapp/frontend/src/hooks/__tests__/usePersistentState.test.tsxanylint ruleapp/frontend/__tests__/errorReporter.smoke.test.tsCreated Files (5)
app/frontend/src/app/error.tsxapp/frontend/src/app/global-error.tsxapp/frontend/src/components/__tests__/ErrorBoundary.test.tsxapp/frontend/src/components/__tests__/ErrorReportingShell.test.tsxapp/frontend/src/__tests__/errorRecovery.test.tsx✅ Acceptance Criteria Checklist
🧪 Testing & Verification
All test suites, type checking, linting, and production builds execute cleanly:
🔒 Security & Privacy Impact
S...), Bearer tokens, JWTs, API keys, passwords, and sensitive dictionary fields are scrubbed from telemetry before network dispatch.CLOSE #531