Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4296 +/- ##
=======================================
Coverage 97.43% 97.44%
=======================================
Files 897 897
Lines 26350 26374 +24
Branches 9517 9523 +6
=======================================
+ Hits 25675 25700 +25
- Misses 632 668 +36
+ Partials 43 6 -37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
01e3a2e to
b83aa6d
Compare
src/error-boundary/internal.tsx
Outdated
| ) : ( | ||
| <ErrorBoundaryImpl | ||
| renderFallback={renderFallback} | ||
| onError={() => null} |
There was a problem hiding this comment.
We don't need to do anything here as we expect such errors to be handled in global event listeners to avoid over-reporting them.
There was a problem hiding this comment.
What are these global listeners? Which telemetry sink do they forward events to?
8f10ee5 to
085ce7b
Compare
| return ( | ||
| <> | ||
| <AppLayoutBuiltInErrorBoundary | ||
| renderFallback={() => ( |
There was a problem hiding this comment.
I don't know how to ensure code coverage here - I expect this code to be executed as a last resort - when (if) something really unexpected happens
eec5798 to
73303c9
Compare
35a0e87 to
974254f
Compare
| const AppLayoutWrapper = hasParentErrorBoundary ? ErrorBoundary : 'div'; | ||
| const appLayoutWrapperProps = hasParentErrorBoundary | ||
| ? { | ||
| onError: (error: any) => | ||
| console.log('The error gets caught by the parent error boundary wrapping app layout: ', error), | ||
| } | ||
| : {}; | ||
|
|
||
| return ( | ||
| <AppLayoutWrapper {...(appLayoutWrapperProps as any)}> |
There was a problem hiding this comment.
Optional comment
How to avoid that many any
const appLayout = <AppLayout ... />;
return hasParentErrorBoundary ? <ErrorBoundary>{appLayout}<ErrorBoundary> : appLayout| }, | ||
|
|
||
| trigger: { | ||
| iconSvg: Symbol() as any, |
There was a problem hiding this comment.
I added a drawer with a broken trigger to test how the error boundary handles it
There was a problem hiding this comment.
Makes sense in hindsight, but it needs an explaining comment that all of this is intentional. Good case for // @ts-expect-error by the way
and same for all intentionally invalid content
There was a problem hiding this comment.
good point. addressed
| <circle stroke-width="2" stroke="currentColor" fill="none" cx="8" cy="8" r="7" /> | ||
| <circle stroke-width="2" stroke="currentColor" fill="none" cx="8" cy="8" r="3" /> | ||
| </svg>`, | ||
| } as any, |
| // Test page for an app layout nested inside another through an iframe. | ||
| // Not a use case that's encouraged. | ||
| 'app-layout/multi-layout-global-drawer-child-layout', | ||
| 'app-layout/with-error-boundaries', |
There was a problem hiding this comment.
I do not see any nested app layouts, why is it skipped?
There was a problem hiding this comment.
Removed. I initially tested it with nested app layouts
There was a problem hiding this comment.
Actually, this is a good idea for a test. That one crashing app layout does not break another
There was a problem hiding this comment.
yes, brought back nested app layouts
| describe.each([true, false])( | ||
| 'entire AppLayout wrapped with error boundary component : %p', | ||
| (wrappedWithErrorBoundary: boolean) => { | ||
| const onError = jest.fn(); |
There was a problem hiding this comment.
Who is going to reset this spy function between tests?
| appLayoutState.widgetizedState; | ||
| return ( | ||
| <> | ||
| <AppLayoutBuiltInErrorBoundary> |
There was a problem hiding this comment.
This is not enough, because the code above is outside the boundary. if there will be any undefined value, the page will crash
Expected implementation is how you did AppLayoutStateProvider. Zero code outside the boundary
You can create a reusable utility for it
function withErrorBoundary(Component) {
return function WithBoundaryComponent() {
return <AppLayoutBuiltInErrorBoundary><Component /></AppLayoutBuiltInErrorBoundary>
}
}
src/error-boundary/internal.tsx
Outdated
| const context = useContext(ErrorBoundariesContext); | ||
| const thisSuppressed = context.suppressed === true || context.suppressed === RootSuppressed; | ||
| const nextSuppressed = suppressNested || thisSuppressed; | ||
| return !thisSuppressed ? ( |
There was a problem hiding this comment.
Who is enabling this suppressing condition? Us or the consuming teams?
The in-widget boundaries should be only controlled by us and only emit metrics to our telemetry sink
There was a problem hiding this comment.
Who is enabling this suppressing condition?
Consumers. This does not suppress in-widget EBs, but forwards suppress conditions down to the components tree. Refactored this code to make it more readable
| wrapper, | ||
| suppressNested = false, | ||
| children, | ||
| renderFallback = () => <></>, |
There was a problem hiding this comment.
Is this argument ever used? I cannot find an example
There was a problem hiding this comment.
Yes, it is used here:
The empty div there instead of a react fragment ensures correct positioning for elements in the header
src/error-boundary/internal.tsx
Outdated
| ) : ( | ||
| <ErrorBoundaryImpl | ||
| renderFallback={renderFallback} | ||
| onError={() => null} |
There was a problem hiding this comment.
What are these global listeners? Which telemetry sink do they forward events to?
| {...context} | ||
| wrapper={wrapper} | ||
| renderFallback={renderFallback} | ||
| className={styles['app-layout-part-fallback']} |
There was a problem hiding this comment.
Does this class goes anywhere? Didn't we discuss that this component renders no DOM? What happened to that discussion?
There was a problem hiding this comment.
Yes, it applies display: contents to the EB root. Without this, components that depend on specific element ordering would break. This ensures they render correctly without adding extra styling.
components/src/error-boundary/styles.scss
Line 11 in d11007e
a25ce49 to
bc5ba19
Compare
|
Still see 3 unresolved discussions Also forgot to call it on the previous review, but we need at least one integration test here. Because this is the only way to test against React 18 in our build |
Description
Error boundaries for AppLayout areas - all areas that load as widgets now have error boundary coverage.
Related links, issue #, if available: n/a
How has this been tested?
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.