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-10894 Rethrow and print registerComponent/registerComponent2 errors #261

Merged
merged 2 commits into from Jul 22, 2020

Conversation

smaifullerton-wk
Copy link
Contributor

@smaifullerton-wk smaifullerton-wk commented Jul 20, 2020

Recommended review: Whitespace changes only

Problem

Currently, registerComponent calls that throw have their errors swallowed by React if they occur in the call stack of a component render (due to the render triggering lazy evaluation of a top-level factory variable).

This can commonly happen if:

  • defaultProps throws
  • propTypes throws
    • can happen when consumedProps throws

Changes:

  • In _registerComponent and _registerComponent2, add a try-catch-rethrow that also logs the error, in case it's swallowed by React
  • Use print instead of window.console.error so it shows up in test output
  • In _registerComponent2 only: add more specific try-catch-rethrows around defaultProps/propTypes accesses, since that's usually what throws
  • Add regression tests that use the prints matcher to verify the error is printed

QA

  • CI passes, unit test coverage should be sufficient unless @greglittlefield-wf feels otherwise

Copy link
Collaborator

@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.

Just a couple small comments, looks great!

lib/react_client.dart Outdated Show resolved Hide resolved
test/react_client_test.dart Outdated Show resolved Hide resolved
@smaifullerton-wk
Copy link
Contributor Author

@greglittlefield-wf thanks, ready

Copy link
Collaborator

@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.

+10

@greglittlefield-wf greglittlefield-wf merged commit 3f71f13 into master Jul 22, 2020
@greglittlefield-wf greglittlefield-wf deleted the cplat-10894-log-registerComponent-errors branch February 16, 2022 21:53
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.

None yet

2 participants