Skip to content

feat: add top-level ErrorBoundary component#1698

Merged
morgan-wowk merged 1 commit intomasterfrom
01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a
Feb 5, 2026
Merged

feat: add top-level ErrorBoundary component#1698
morgan-wowk merged 1 commit intomasterfrom
01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a

Conversation

@morgan-wowk
Copy link

@morgan-wowk morgan-wowk commented Jan 26, 2026

Description

Added a new ErrorBoundary component that wraps the entire application to catch and handle React errors. The component integrates with Bugsnag for error reporting when enabled, with a fallback option for when Bugsnag is not available. The implementation includes a custom error handler UI component and has been integrated at the root level of the application.

Type of Change

  • New feature
  • Improvement

Checklist

  • I have tested this does not break current pipelines / runs functionality
  • I have tested the changes on staging

Test Instructions

  1. Verify the application loads correctly with the new error boundary in place
  2. Test error handling by intentionally causing a component error
  3. Confirm errors are properly reported to Bugsnag when configured

Copy link
Author

morgan-wowk commented Jan 26, 2026

@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_unified_errorhandler_component_add_errorhandler_to_unify_error_handling_logic_for_both_react_error_boundaries_and_router_errors._automatically_reports_errors_to_bugsnag_and_provides_consistent_error_display_with_retry_g branch from 0fa7ae0 to b8f873e Compare January 26, 2026 21:02
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch 2 times, most recently from 6b11c41 to fe1d7b6 Compare January 26, 2026 21:07
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_unified_errorhandler_component_add_errorhandler_to_unify_error_handling_logic_for_both_react_error_boundaries_and_router_errors._automatically_reports_errors_to_bugsnag_and_provides_consistent_error_display_with_retry_g branch 2 times, most recently from 2f5f3a3 to bedeb6d Compare January 26, 2026 21:10
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch from fe1d7b6 to 8a682a5 Compare January 26, 2026 21:10
@morgan-wowk morgan-wowk marked this pull request as ready for review January 26, 2026 21:13
@morgan-wowk morgan-wowk requested a review from a team as a code owner January 26, 2026 21:13
Comment on lines 43 to 45
// Fallback: no error boundary (just render children)
// In the future, this could check for other error reporting services
return <>{children}</>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can use ErrorBoundary from react-error-boundary package (which is already in). You may read more in https://kentcdodds.com/blog/use-react-error-boundary-to-handle-errors-in-react or start from https://www.npmjs.com/package/react-error-boundary

Copy link
Author

Choose a reason for hiding this comment

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

Implemented.

@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch from 8a682a5 to f544686 Compare January 28, 2026 18:33
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_unified_errorhandler_component_add_errorhandler_to_unify_error_handling_logic_for_both_react_error_boundaries_and_router_errors._automatically_reports_errors_to_bugsnag_and_provides_consistent_error_display_with_retry_g branch from bedeb6d to 2b4b0cd Compare January 28, 2026 18:33
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch from f544686 to 5d61c09 Compare January 28, 2026 18:48
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_unified_errorhandler_component_add_errorhandler_to_unify_error_handling_logic_for_both_react_error_boundaries_and_router_errors._automatically_reports_errors_to_bugsnag_and_provides_consistent_error_display_with_retry_g branch from 2b4b0cd to 7e226d9 Compare January 28, 2026 18:48
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch from 5d61c09 to 9dafa4a Compare January 28, 2026 19:21
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_unified_errorhandler_component_add_errorhandler_to_unify_error_handling_logic_for_both_react_error_boundaries_and_router_errors._automatically_reports_errors_to_bugsnag_and_provides_consistent_error_display_with_retry_g branch from 7e226d9 to 9322f42 Compare January 28, 2026 19:21
Copy link
Author

Note: I am actively working on implementing a refactor to simplify the contents of this PR

@morgan-wowk morgan-wowk changed the base branch from 01-26-feat_add_unified_errorhandler_component_add_errorhandler_to_unify_error_handling_logic_for_both_react_error_boundaries_and_router_errors._automatically_reports_errors_to_bugsnag_and_provides_consistent_error_display_with_retry_g to graphite-base/1698 January 28, 2026 19:54
@morgan-wowk morgan-wowk changed the base branch from graphite-base/1698 to 01-26-refactor-error-component-names January 28, 2026 19:54
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch from 9dafa4a to 8415728 Compare January 28, 2026 19:57
@morgan-wowk morgan-wowk force-pushed the 01-26-refactor-error-component-names branch from 9322f42 to 43d5e44 Compare January 28, 2026 19:57
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch from 89f0750 to 8d037cb Compare January 28, 2026 22:34
@morgan-wowk morgan-wowk force-pushed the 01-26-refactor-error-component-names branch 2 times, most recently from 15c6748 to 61c8e8c Compare February 3, 2026 21:47
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch 2 times, most recently from 2902339 to ed1e34c Compare February 3, 2026 21:49
@morgan-wowk morgan-wowk force-pushed the 01-26-refactor-error-component-names branch 2 times, most recently from 7c245df to 70faa8f Compare February 3, 2026 21:50
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch from ed1e34c to 6e0d9af Compare February 3, 2026 21:50
@morgan-wowk morgan-wowk force-pushed the 01-26-refactor-error-component-names branch from 70faa8f to 962f3c9 Compare February 3, 2026 21:54
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch from 6e0d9af to 58105fb Compare February 3, 2026 21:54

const handleRefresh = () => {
reset?.();
resetFn?.();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I mentioned this in the other PR, but maybe we just add a default value to reset so we don't have to conditionally render this function call?

Copy link
Author

Choose a reason for hiding this comment

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

Yup! Done

export const ErrorBoundary = ({ children }: ErrorBoundaryProps) => {
if (isBugsnagEnabled()) {
const BugsnagBoundary =
Bugsnag.getPlugin("react")!.createErrorBoundary(React);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The non-null assertion (!) here could cause a runtime crash if the React plugin isn't properly initialized. We should avoid non-null assertions and add explicit null checks instead.

const reactPlugin = Bugsnag.getPlugin("react");
if (!reactPlugin) {
  console.error("Bugsnag React plugin not initialized");
  return (
    <ReactErrorBoundary FallbackComponent={ErrorPage}>
      {children}
    </ReactErrorBoundary>
  );
}
const BugsnagBoundary = reactPlugin.createErrorBoundary(React);

This gracefully falls back to the standard ReactErrorBoundary if Bugsnag's plugin fails to load, rather than crashing the entire app.

Copy link
Author

Choose a reason for hiding this comment

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

Added the safety check and fallback to react error boundary

Copy link
Collaborator

@Mbeaulne Mbeaulne left a comment

Choose a reason for hiding this comment

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

some smallish changes

@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch from 58105fb to d007c8f Compare February 5, 2026 22:20
@morgan-wowk morgan-wowk force-pushed the 01-26-refactor-error-component-names branch from 962f3c9 to 5301a3c Compare February 5, 2026 22:20
@morgan-wowk morgan-wowk force-pushed the 01-26-refactor-error-component-names branch from 5301a3c to cebab76 Compare February 5, 2026 22:34
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch from d007c8f to eff2df2 Compare February 5, 2026 22:44
@morgan-wowk morgan-wowk force-pushed the 01-26-refactor-error-component-names branch 3 times, most recently from 22efe5e to fbedc98 Compare February 5, 2026 22:48
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch from eff2df2 to 323067b Compare February 5, 2026 22:48
@morgan-wowk morgan-wowk changed the base branch from 01-26-refactor-error-component-names to graphite-base/1698 February 5, 2026 22:52
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch from 323067b to 4d002ca Compare February 5, 2026 22:56
@graphite-app graphite-app bot changed the base branch from graphite-base/1698 to master February 5, 2026 22:56
Add decoupled ErrorBoundary component that determines which error
reporting service to use. Currently supports Bugsnag, but designed
to be extensible for other services. Integrate into app root.
@morgan-wowk morgan-wowk force-pushed the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch from 4d002ca to 4e110c2 Compare February 5, 2026 22:56
Copy link
Author

morgan-wowk commented Feb 5, 2026

Merge activity

  • Feb 5, 10:58 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 5, 10:58 PM UTC: @morgan-wowk merged this pull request with Graphite.

@morgan-wowk morgan-wowk merged commit 8b7b181 into master Feb 5, 2026
8 checks passed
@morgan-wowk morgan-wowk deleted the 01-26-feat_add_top-level_errorboundary_component_add_decoupled_errorboundary_component_that_determines_which_error_reporting_service_to_use._currently_supports_bugsnag_but_designed_to_be_extensible_for_other_services._integrate_into_a branch February 5, 2026 22:58
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.

3 participants