-
Notifications
You must be signed in to change notification settings - Fork 426
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: add error boundary for form input components #6869
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
No changes to documentation |
33e0a91
to
03b9cb0
Compare
Component Testing Report Updated Jun 7, 2024 12:47 AM (UTC)
|
* when there are no errors. | ||
* @internal | ||
*/ | ||
function ErrorCard(props: {error: unknown; onRetry: () => void}) { |
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.
The unknown type here and the stack
and message
params become a little confusing for me here, but I understand if it's more difficult to more strictly type things 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.
It follows the precedence in StudioErrorBoundary
, as well as the convention of the stricter TS rule that enforces:
try {
doSomething()
} catch(error: unknown) {
// `error` is never guaranteed to be a subclass of `Error` and can be anything, `unknown` forces you to deal with every eventuality
}
Which is also why the isRecord
asserters are used further down
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.
ahh, of course! apologies for not checking that
88aaa8c
to
9e81d00
Compare
9e81d00
to
1f64bfb
Compare
Description
While debugging issues in React 19, as well as React Compiler, I've frequently encountered crashes that takes down the Structure Tool completely:
It's difficult to track down exactly what's causing it, the same is true when handling user reports of crashes, in Next v14 and v15 embedded studios in particular.
This PR adds an error boundary for input components, which narrows down the crash to the input level:
In the image above only some of the Portable Text Editor inputs are crashing, significantly helping with narrowing down the cause. Fixes for the errors seen here will be done in follow up PRs.
What to review
Does the language strings and the UI make sense?
Testing
It's easiest to test on the compiled studio deployment, as it crashes early on race condition issues, instead of requiring tricky race condition reproduction steps: https://test-compiled-studio-git-add-input-error-boundary.sanity.build/test/structure/input-standard;portable-text;pt_allTheBellsAndWhistles;7455ba88-75d5-4a77-94a4-91738fa670c5
Notes for release
Form input components now have their own error boundaries, limiting crashes to a field level on a document form, instead of taking down the entire Structure Tool.