Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPLAT-8600: Unrecoverable ErrorBoundary Fix #435

Merged
merged 14 commits into from
Dec 18, 2019

Conversation

kealjones-wk
Copy link
Contributor

@kealjones-wk kealjones-wk commented Dec 4, 2019

Motivation

Even with ErrorBoundaries in place, we were seeing issues with the app still entirely unmounting even with the logic for "unrecoverable" errors. It turns out in React if an ErrorBoundary catches an error, it will have its error lifecycle methods called, if on that render cycle the component throws during the render cycle React will move up the tree to a parent ErrorBoundary instead. And due to all the Previous ErrorBoundaries having the same logic none would ever handle the render cycle error.

Changes

  • Updated ErrorBoundaryComponent to handle render cycle unrecoverable errors (hopefully this wont happen often.)
  • Moved the previous ErrorBoundary logic into RecoverableErrorBoundary and nested it as the first child of the updated ErrorBoundary.
    • This nesting allows us to know that if RecoverableErrorBoundary was unable to recover, that the error is "Unrecoverable" and needs to be handled.

Release Notes

  • Updated ErrorBoundary to better handle Unrecoverable Errors that might be thrown during the render cycle.
  • Deprecated ErrorBoundaryMixin as it only handles errors that are able to be "recovered" and recommend using ErrorBoundary with your custom props instead.

Review

See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.

Please review:

QA Checklist

  • Tests were updated and provide good coverage of the changeset and other affected code
  • Manual testing was performed if needed

Merge Checklist

While we perform many automated checks before auto-merging, some manual checks are needed:

  • A Client Platform member has reviewed these changes
  • There are no unaddressed comments - this check can be automated if reviewers use the "Request Changes" feature
  • For release PRs - Version metadata in Rosie comment is correct

@aviary2-wf
Copy link

aviary2-wf commented Dec 4, 2019

Security Insights

The items listed below may not capture all security relevant changes. Before providing a security review, be sure to review the entire PR for security impact.

(1) Security relevant changes were detected
  • Watched keyword InnerHtml in lib/src/component/error_boundary.dart line(s) ['100'] added
  • Action Items

    • Obtain a security review; reviewer should pay special attention to insights listed above
    • Verify aviary.yaml coverage of security relevant code

    Questions or Comments? Reach out on Slack: #support-infosec.

    * master:
      lower dockerfile to 2.6 instead of 2.7
      wdesk sdk hasnt upped its pubspec yet...
      remove dart 2.4 references
      address cr feedback
      fix tests for redux 7.1.3
      Update CHANGELOG.md
      over_react_3.1.6
      remove unneeded `if`
      commit updated generated file from redux
      Remove dead code & help dart2js compile perf
      Add comment
      Update test/over_react/component_declaration/builder_integration_tests/component2/required_accessor_integration_test.dart
      Apply suggestions from code review
      Update dependency validator
      Add front_end dependency
      Format a little
      Address CR feedback
      Refactor required accessor integration suite
      Refactor required accessor test suite
    @kealjones-wk kealjones-wk marked this pull request as ready for review December 12, 2019 22:43
    expect(getByTestId(jacket.getInstance(), 'fallbackNode'), isNotNull);
    if (!isWrapper) {
    // wrapper ErrorBoundary doesn't use `props.fallbackUIRenderer` because `ResolvableErrorBoundary`
    // will display it on first error. Meaning wrapper ErrorBoundary will never be reached if it is set.
    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    The child error boundary catching and displaying the fallback renderer is tested here:
    https://github.com/Workiva/over_react/pull/435/files#diff-89d97c9289557c366adc6964193a6057R372-R388

    class FaultyOnMountComponent extends UiComponent2<FaultyOnMountProps> {
    @override
    render() {
    throw Shade();
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    you win the internet today Keal

    Copy link
    Contributor

    @greglittlefield-wf greglittlefield-wf left a comment

    Choose a reason for hiding this comment

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

    +1

    Nothin but nits

    @@ -13,6 +13,8 @@ const String defaultErrorBoundaryLoggerName = 'over_react.ErrorBoundary';
    /// within a custom component.
    ///
    /// > See: [ErrorBoundaryMixin] for a usage example.
    @Deprecated('Building custom error boundaries with this mixin will no longer be supported in version 4.0.0.'
    'Use ErrorBoundary and its prop API to customize error handling instead.')
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    NICE

    @kealjones-wk
    Copy link
    Contributor Author

    +1

    Nothin but nits

    swish!

    Copy link
    Contributor

    @aaronlademann-wf aaronlademann-wf left a comment

    Choose a reason for hiding this comment

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

    +1

    Copy link
    Contributor

    @aaronlademann-wf aaronlademann-wf left a comment

    Choose a reason for hiding this comment

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

    QA +1

    • Passing CI
    • Pulled these changes into a consumer app in which I updated a component that is a child of an ErrorBoundary to throw from within render.
      • Without these changes, throwing from within render resulted in the entire app being unmounted.
      • With these changes, only the problematic component was unmounted, and the rest of the application continued to work as expected.

    Nice work on this @kealjones-wk !!!

    @evanweible-wf
    Copy link
    Contributor

    Security +1

    • Watched term InnerHtml was flagged, but it's actually just a part of a test ID.

    @kealjones-wk
    Copy link
    Contributor Author

    @Workiva/release-management-p

    @rmconsole7-wk rmconsole7-wk merged commit bde6993 into master Dec 18, 2019
    @rmconsole7-wk rmconsole7-wk deleted the errorboundary_unrecoverable branch December 18, 2019 17:58
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    8 participants