@@ -17,9 +17,39 @@ import { isBuild } from './utils/isBuild';
1717export * from '@sentry/node' ;
1818export { captureUnderscoreErrorException } from '../common/_error' ;
1919
20- // Here we want to make sure to only include what doesn't have browser specifics
21- // because or SSR of next.js we can only use this.
22- export { ErrorBoundary , showReportDialog , withErrorBoundary } from '@sentry/react' ;
20+ /**
21+ * A passthrough error boundary for the server that doesn't depend on any react. Error boundaries don't catch SSR errors
22+ * so they should simply be a passthrough.
23+ */
24+ export const ErrorBoundary = ( props : React . PropsWithChildren < unknown > ) : React . ReactNode => {
25+ if ( ! props . children ) {
26+ return null ;
27+ }
28+
29+ if ( typeof props . children === 'function' ) {
30+ return ( props . children as ( ) => React . ReactNode ) ( ) ;
31+ }
32+
33+ // since Next.js >= 10 requires React ^16.6.0 we are allowed to return children like this here
34+ return props . children as React . ReactNode ;
35+ } ;
36+
37+ /**
38+ * A passthrough error boundary wrapper for the server that doesn't depend on any react. Error boundaries don't catch
39+ * SSR errors so they should simply be a passthrough.
40+ */
41+ export function withErrorBoundary < P extends Record < string , any > > (
42+ WrappedComponent : React . ComponentType < P > ,
43+ ) : React . FC < P > {
44+ return WrappedComponent as React . FC < P > ;
45+ }
46+
47+ /**
48+ * Just a passthrough since we're on the server and showing the report dialog on the server doesn't make any sense.
49+ */
50+ export function showReportDialog ( ) : void {
51+ return ;
52+ }
2353
2454const globalWithInjectedValues = global as typeof global & {
2555 __rewriteFramesDistDir__ : string ;
0 commit comments