Skip to content

feat: implement comprehensive React error boundary framework - #5690

Closed
anshgoyalevil wants to merge 1 commit into
asyncapi:masterfrom
anshgoyalevil:anshgoyal/err-bdry
Closed

feat: implement comprehensive React error boundary framework#5690
anshgoyalevil wants to merge 1 commit into
asyncapi:masterfrom
anshgoyalevil:anshgoyal/err-bdry

Conversation

@anshgoyalevil

@anshgoyalevil anshgoyalevil commented Aug 5, 2026

Copy link
Copy Markdown
Member

Add a reusable ErrorBoundary class component with getDerivedStateFromError and componentDidCatch, dynamic fallback injection, a reset mechanism, and automatic route-based reset via Next.js Router events.

Add accessible fallback UIs: a full-page GlobalErrorFallback (icon, explanation, Try Again, home link) and a lightweight ContextualErrorFallback card for widgets/sidebars, both WCAG 2.1 AA keyboard/screen-reader friendly.

Wire boundaries as a global safety net in pages/_app.tsx and around content containers in Layout, DocsLayout, and BlogLayout so navigation and sidebars stay functional when page content crashes. Includes Storybook stories.

Closes #5559

Related issue(s)

Summary by CodeRabbit

  • New Features
    • Added error handling that prevents isolated page sections from crashing the entire app.
    • Added contextual retry prompts for affected sections.
    • Added a full-page error screen with retry and homepage navigation options.
    • Added recovery when navigation changes or users retry failed content.
  • Bug Fixes
    • Improved resilience across application, documentation, blog, and page layouts when rendering errors occur.
  • Tests
    • Added interactive examples covering global, contextual, custom, recovered, and error-free states.

@netlify

netlify Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1a66607
🔍 Latest deploy log https://app.netlify.com/projects/asyncapi-website/deploys/6a73804201bb110008aff0ea
😎 Deploy Preview https://deploy-preview-5690--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 624cc520-cfbc-4175-bc28-b5d7bc6b6d83

📥 Commits

Reviewing files that changed from the base of the PR and between 0aae184 and 1a66607.

📒 Files selected for processing (10)
  • components/error/ContentErrorBoundary.tsx
  • components/error/ContextualErrorFallback.tsx
  • components/error/ErrorBoundary.stories.tsx
  • components/error/ErrorBoundary.tsx
  • components/error/GlobalErrorFallback.tsx
  • components/layout/BlogLayout.tsx
  • components/layout/DocsLayout.tsx
  • components/layout/Layout.tsx
  • pages/_app.tsx
  • types/components/error/ErrorBoundaryProps.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • components/layout/DocsLayout.tsx
  • components/error/ErrorBoundary.stories.tsx
  • types/components/error/ErrorBoundaryProps.ts
  • pages/_app.tsx
  • components/layout/Layout.tsx
  • components/layout/BlogLayout.tsx

📝 Walkthrough

Walkthrough

Adds a typed React error boundary framework with global and contextual fallback UIs, retry and route-change recovery, Storybook coverage, and wrappers around application and layout content.

Changes

Error boundary framework

Layer / File(s) Summary
Fallback contracts and interfaces
types/components/error/ErrorBoundaryProps.ts, components/error/GlobalErrorFallback.tsx, components/error/ContextualErrorFallback.tsx, components/error/ContentErrorBoundary.tsx
Defines fallback and boundary types. Adds global and contextual fallback components and a reusable content boundary.
Boundary lifecycle and fallback rendering
components/error/ErrorBoundary.tsx, components/error/ErrorBoundary.stories.tsx
Adds descendant error capture, error reporting, imperative and automatic resets, route-change recovery, fallback selection, and Storybook scenarios.
Application and layout integration
pages/_app.tsx, components/layout/BlogLayout.tsx, components/layout/DocsLayout.tsx, components/layout/Layout.tsx
Wraps application, blog, documentation, and layout content with error boundaries.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Descendant
  participant ErrorBoundary
  participant Fallback
  participant NextRouter
  Descendant->>ErrorBoundary: render throws Error
  ErrorBoundary->>Fallback: render fallback with error and reset
  Fallback->>ErrorBoundary: invoke reset
  ErrorBoundary->>Descendant: render children again
  NextRouter->>ErrorBoundary: route change completes
  ErrorBoundary->>Descendant: reset errored state
Loading

Suggested reviewers: akshatnema, asyncapi-bot-eve, derberg

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: a comprehensive React error boundary framework.
Linked Issues check ✅ Passed The changes implement the reusable boundary, route reset, global and granular placement, fallback UIs, and Storybook coverage required by issue #5559.
Out of Scope Changes check ✅ Passed All changes support issue #5559, including error boundaries, fallback components, layout integration, types, and related Storybook stories.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: dependency version conflict. Check your lock file or package.json.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@asyncapi-bot

asyncapi-bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 49
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-5690--asyncapi-website.netlify.app/

@asyncapi asyncapi deleted a comment from sonarqubecloud Bot Aug 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@components/error/ErrorBoundary.tsx`:
- Around line 69-84: Update componentDidUpdate to detect changes to
resetOnRouteChange and register or remove the Router.events routeChangeComplete
listener so it matches the current prop value. Keep the existing resetKeys
handling intact, and make componentWillUnmount unconditionally remove the
listener regardless of the prop value.

In `@components/layout/BlogLayout.tsx`:
- Line 95: Replace the omitted fallbacks on the nested ErrorBoundary instances
with render-function fallbacks that render ContextualErrorFallback, preserving
local recovery UI for each content region. Apply this to the blog article in
components/layout/BlogLayout.tsx:95-95, explorer and documentation content in
components/layout/DocsLayout.tsx:115-117 and 204-206, and post and default page
content in components/layout/Layout.tsx:59-63 and 66-70.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d956c04d-4e08-4706-b7ff-bd460d450020

📥 Commits

Reviewing files that changed from the base of the PR and between 0aae184 and 3d6dd48.

📒 Files selected for processing (9)
  • components/error/ContextualErrorFallback.tsx
  • components/error/ErrorBoundary.stories.tsx
  • components/error/ErrorBoundary.tsx
  • components/error/GlobalErrorFallback.tsx
  • components/layout/BlogLayout.tsx
  • components/layout/DocsLayout.tsx
  • components/layout/Layout.tsx
  • pages/_app.tsx
  • types/components/error/ErrorBoundaryProps.ts

Comment thread components/error/ErrorBoundary.tsx
Comment thread components/layout/BlogLayout.tsx Outdated
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Add a reusable ErrorBoundary class component with getDerivedStateFromError
and componentDidCatch, dynamic fallback injection, a reset mechanism, and
automatic route-based reset via Next.js Router events.

Add accessible fallback UIs: a full-page GlobalErrorFallback (icon,
explanation, Try Again, home link) used as the app-wide safety net, and a
lightweight ContextualErrorFallback card (via ContentErrorBoundary) for
content regions so a failed section keeps a local inline recovery UI. Both
are WCAG 2.1 AA keyboard/screen-reader friendly.

Wire boundaries as a global safety net in pages/_app.tsx and around content
containers in Layout, DocsLayout, and BlogLayout so navigation and sidebars
stay functional when page content crashes. Includes Storybook stories.

Closes asyncapi#5559
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

@anshgoyalevil

Copy link
Copy Markdown
Member Author

Superseded by #5691 (branch history was accidentally rewritten). Continuing the work there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE] Implement Comprehensive React Error Boundary Framework

2 participants