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

feat(POC): add error boundary to withSuspense #10824

Merged
merged 48 commits into from
Oct 8, 2024
Merged

Conversation

gkartalis
Copy link
Member

@gkartalis gkartalis commented Sep 20, 2024

This PR resolves PHIRE-1019 and PHIRE-1109

Description

Introduced an errorFallback component in case something goes wrong, devs can override by passing their custom errorfallback.

We also introduced react-error-boundary dep that is recommended from react official docs over the standard react one and also utilized the onError callback to report the errors on Sentry.

Makes withSuspense hook now require passing a fallback component.

Stops tracking updated components that are now not dead ends.

Updates all components now using withSuspense to pass a fallback using following patterns:

Subcomponents whose absences does not hinder the user much just don't render it in case of error - examples - home screen sections and filter sections:

Examples

subcomponent

no-rail

Full screen component and there is an existing error component available show that, make sure nav is available

Examples

full-screen-with-existing-error-2

full-screen-with-existing-error

fullscreen-with-existing-error

new-works-for-you-error

activity-error

Full screen component with no error component available, use our LoadFailureView, make sure nav is available

Examples

fullscreen-back

fullscreen

Follow-ups

  • We should avoid the Unable to load view and try to get some error states more like pattern 2 across surfaces, Unable to load is ugly and doesn't lay out well in many cases

How to test

You can connect local metaphysics to eigen locally and throw an error from the query from any point that we do use the withSuspense

PR Checklist

  • I have tested my changes on iOS and Android.
  • I hid my changes behind a feature flag, or they don't need one.
  • I have included screenshots or videos, or I have not changed the UI.
  • I have added tests, or my changes don't require any.
  • I added an app state migration, or my changes do not require one.
  • I have documented any follow-up work that this PR will require, or it does not require any.
  • I have added a changelog entry below, or my changes do not require one.

To the reviewers 👀

  • I would like at least one of the reviewers to run this PR on the simulator or device.
Changelog updates

Changelog updates

Cross-platform user-facing changes

iOS user-facing changes

Android user-facing changes

Dev changes

  • add error boundary to withSuspense - gkartalis

Need help with something? Have a look at our docs, or get in touch with us.

@gkartalis
Copy link
Member Author

Important

Before merging we need to test out how the default error fallback will behave in the already existing surfaces.
While testing it out I realised that it does successfully hide defensively the failed surface but if this surface is a screen it does create a dead-end on the ui since it fails silently (sends error to sentry) and renders null in the screen.

Ideas welcome on that @damassi @MounirDhahri @brainbicycle

@MounirDhahri
Copy link
Member

How does the new ErrorBoundary look like? is it different than the existent RetryErrorBounday ?

@gkartalis
Copy link
Member Author

in this one we basically can override the behaviour with any fallback. But the default is null so it creates a dead end if it is used by a screen. On the other hand if it is a rail it just defensively hides it

@MounirDhahri
Copy link
Member

By dead end do you mean we will show this?

@ArtsyOpenSource
Copy link
Contributor

ArtsyOpenSource commented Oct 2, 2024

This PR contains the following changes:

  • Dev changes (add error boundary to withSuspense - gkartalis)

Generated by 🚫 dangerJS against 0b621bf

@brainbicycle
Copy link
Contributor

this ready for review! @gkartalis

>
<Component {...props} />
</Suspense>
</ErrorBoundary>
Copy link
Contributor

Choose a reason for hiding this comment

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

main change, make error fallback required prop and use the react-error-boundary

+
+
+ const metaphysicsRejectionTests = {
+ query: "query HomeAboveTheFoldQuery",
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a test patch that can be used for testing failures, move to patches, reinstall deps, then update the query here to cause it to reject

Copy link
Contributor

Choose a reason for hiding this comment

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

forgot a step, need to turn off persisted queries to effectively match queries, I may add a dev toggle for that if we don't remove it entirely

Copy link
Member Author

@gkartalis gkartalis left a comment

Choose a reason for hiding this comment

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

amazing, looks great! Left only a small question. I can't approve since I am the one who opened the PR but consider it approved

@damassi
Copy link
Member

damassi commented Oct 8, 2024

For the LoadFailureView, should we also add a reload button? That might be a bit nicer and give the user some retry ability (assuming we can preserve the navigation stack)

Amazing work y'all! This is a really huge improvement.

@brainbicycle
Copy link
Contributor

For the LoadFailureView, should we also add a reload button? That might be a bit nicer (assuming we can preserve the navigation stack)

Amazing work y'all! This is a really huge improvement.

good point the loadfailureview does support that but we need to pass a function to onRetry, let me see if anything makes sense here.

@brainbicycle
Copy link
Contributor

For the LoadFailureView, should we also add a reload button? That might be a bit nicer and give the user some retry ability (assuming we can preserve the navigation stack)

Amazing work y'all! This is a really huge improvement.

done!

Copy link
Member

@damassi damassi left a comment

Choose a reason for hiding this comment

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

+1000

@brainbicycle brainbicycle merged commit 23c860d into main Oct 8, 2024
7 checks passed
@brainbicycle brainbicycle deleted the gkartalis/PHIRE-1019 branch October 8, 2024 19:52
anandaroop added a commit that referenced this pull request Oct 10, 2024
anandaroop added a commit that referenced this pull request Oct 10, 2024
…rrent Galleries section component (#10922)

* feat: support HomeViewSectionCard with a default full-width presentation

* chore: remove HomeViewSectionGalleries

This section type was a bit of a misnomer and never actually
served up a galleries connection. We remove it here, with the
possibility of bring it back such a component when it is actually
needed

* refactor: allow navigating to route that is a non-canonical web href

* fix: withSuspense usage after #10824

* chore: bump schema
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.

5 participants