-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Display an error message when the service is unreachable #8490
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR improves error handling when the backend service is unreachable by removing blocking UI behavior and adding clear error messaging.
- Removed
ClientConfigProvider
component to prevent UI blocking when client config fails to load - Added error snackbar notification in
ClientConfigProviderEffect
when backend is unreachable - Added
isClientConfigLoaded
check inUserProviderEffect
to prevent unnecessary network requests - Modified
PageChangeEffect
to check client config status before tracking analytics - Updated test decorators to reflect new non-blocking architecture
6 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile
<ClientConfigProviderEffect /> | ||
<ClientConfigProvider> | ||
<ChromeExtensionSidecarEffect /> | ||
<ChromeExtensionSidecarProvider> | ||
<UserProviderEffect /> | ||
<UserProvider> | ||
<AuthProvider> | ||
<ApolloMetadataClientProvider> | ||
<ObjectMetadataItemsProvider> | ||
<PrefetchDataProvider> | ||
<AppThemeProvider> | ||
<SnackBarProvider> | ||
<DialogManagerScope dialogManagerScopeId="dialog-manager"> | ||
<DialogManager> | ||
<StrictMode> | ||
<PromiseRejectionEffect /> | ||
<GotoHotkeysEffectsProvider /> | ||
<PageTitle title={pageTitle} /> | ||
<Outlet /> | ||
</StrictMode> | ||
</DialogManager> | ||
</DialogManagerScope> | ||
</SnackBarProvider> | ||
</AppThemeProvider> | ||
</PrefetchDataProvider> | ||
<PageChangeEffect /> | ||
</ObjectMetadataItemsProvider> | ||
</ApolloMetadataClientProvider> | ||
</AuthProvider> | ||
</UserProvider> | ||
</ChromeExtensionSidecarProvider> | ||
</ClientConfigProvider> | ||
<ChromeExtensionSidecarEffect /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: ClientConfigProviderEffect and ChromeExtensionSidecarEffect may try to make API calls before SnackBarProvider is mounted, potentially losing error messages
if (error !== undefined) { | ||
enqueueSnackBar('Unable to reach backend', { | ||
variant: SnackBarVariant.Error, | ||
}); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: setIsClientConfigLoaded(false) should be called here to ensure the state accurately reflects the failed load
@@ -90,5 +102,7 @@ export const ClientConfigProviderEffect = () => { | |||
setIsAnalyticsEnabled, | |||
]); | |||
|
|||
console.log('error: ', error, loading); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: remove console.log before merging to production
<ClientConfigProviderEffect /> | ||
<ClientConfigProvider> | ||
<UserProviderEffect /> | ||
<UserProvider> | ||
<ApolloMetadataClientMockedProvider> | ||
<ObjectMetadataItemsProvider> | ||
<FullHeightStorybookLayout> | ||
<HelmetProvider> | ||
<SnackBarProviderScope snackBarManagerScopeId="snack-bar-manager"> | ||
<IconsProvider> | ||
<PrefetchDataProvider> | ||
<Outlet /> | ||
</PrefetchDataProvider> | ||
</IconsProvider> | ||
</SnackBarProviderScope> | ||
</HelmetProvider> | ||
</FullHeightStorybookLayout> | ||
</ObjectMetadataItemsProvider> | ||
</ApolloMetadataClientMockedProvider> | ||
</UserProvider> | ||
</ClientConfigProvider> | ||
<UserProviderEffect /> | ||
<UserProvider> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: UserProviderEffect depends on client config being loaded, but now runs regardless of client config status. This could cause cascading errors if client config fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's causing any issues here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
This PR continues the error handling improvements by implementing comprehensive error capture and display mechanisms across the application.
- Added
PromiseRejectionEffect
to catch and display unhandled promise rejections via snackbar - Moved
ClientConfigProviderEffect
afterSnackBarProvider
in provider hierarchy to ensure error messages are displayed - Added error handling for
ObjectMetadataItemNotFoundError
with specific error message - Added Sentry integration placeholder in
PromiseRejectionEffect
for future error tracking
3 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
}); | ||
return; | ||
} | ||
if (isDefined(data?.clientConfig)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: consider adding an else clause to handle undefined clientConfig case explicitly
Thanks a lot!!! |
Fixes #8487
Summary
We block the rest of the UI if we fail to fetch client config from the back-end for whatever reason. Therefore, a white screen is displayed without any feedback whenever that happens.
ClientConfigProvider
is the component that blocks UI when the client config has not been loaded.Solution
It ended up being more changes than I anticipated but those changes were necessary. I removed
ClientConfigProvider
to unblock the rest of the UI even if the back-end is unreachable. UsedenqueueSnackBar
to display an error message when the client config failed to load. UsedisClientConfigLoaded
in a couple of places to ensure no further requests are made if client config fetch fails.Recording
CleanShot.2024-11-13.at.17.01.03.mp4
Honestly, I am unsure if it's the best way to tackle the issue, but I'd like to receive feedback on this.