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

[Request] Set error boundary for component subtrees #950

Closed
Tracked by #1068
tthvo opened this issue Apr 13, 2023 · 3 comments
Closed
Tracked by #1068

[Request] Set error boundary for component subtrees #950

tthvo opened this issue Apr 13, 2023 · 3 comments
Labels
feat New feature or request good first issue Good for newcomers

Comments

@tthvo
Copy link
Member

tthvo commented Apr 13, 2023

Describe the feature

Sometimes, if there are something wrong (e.g. bugs or local storage is tampered with invalid values), the console will crash with plain screen.

This is not very nice UX. We should show some error message so that the users can move on to other views and also report the issue quickly without tracing browser console.

Any other information?

See https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary

Though we need to consider where to put the boundary so that its not redundant: https://aweary.dev/fault-tolerance-react/

Attention

From: https://stackoverflow.com/questions/48482619/how-can-i-make-use-of-error-boundaries-in-functional-react-components

Also bear in mind that try/catch blocks won't work on all cases.
If a component deep in the hierarchy tries to updates and fails, the try/catch block in one of the parents won't work -- > because it isn't necessarily updating together with the child.

@tthvo tthvo added good first issue Good for newcomers feat New feature or request needs-triage Needs thorough attention from code reviewers labels Apr 13, 2023
@tthvo tthvo moved this to Todo in 2.4.0 release Apr 13, 2023
@andrewazores
Copy link
Member

This was something I had wanted to look into for a while. The SO snippets above look pretty straightforward - maybe we can get a single error boundary in place within the AppLayout or somewhere else high up in our component tree by tomorrow? This way at least if there is some such bug, the user is likely to at least still see the general Cryostat frame and navigation menu so they can try clicking away to a non-bugged view. Better handling for specific views can be targeted for a later release.

@andrewazores andrewazores moved this to Stretch Goals in 2.3.0 release Apr 13, 2023
@andrewazores andrewazores removed the needs-triage Needs thorough attention from code reviewers label Apr 13, 2023
@tthvo tthvo self-assigned this Apr 13, 2023
@tthvo tthvo removed their assignment Apr 13, 2023
@andrewazores andrewazores moved this from Todo to Backlog in 2.4.0 release May 23, 2023
@andrewazores
Copy link
Member

I think this can be closed now. There might be more places where this technique can be applied but it has been working well for some time as it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request good first issue Good for newcomers
Projects
No open projects
Status: Stretch Goals
Status: Backlog
Development

No branches or pull requests

2 participants