bigbluebutton-Github/bigbluebutton-html5/client/main.tsx
prlanzarin b6a962ff73 fix: not all error boundaries should close audio/Apollo
Currently, all error boundaries close audio and Apollo connections once
an error is caught. This is not the correct behavior as not all error
boundaries are critical, e.g.: the presentation crashing should _not_
break the whole client. It also deviates from how error boundaries
worked in 2.7

Add a new prop to the ErrorBoundary/LocatedErrorBoundary components
called isCritical that flags an error boundary instance as critical. If
true, it'll close Apollo/audio. The default behavior is
isCritical=false, and the only critical error boundaries are the ones
located in the app's root (/client/main.tsx).
2024-09-10 19:00:47 +00:00

74 lines
2.7 KiB
TypeScript

import React from 'react';
import ConnectionManager from '/imports/ui/components/connection-manager/component';
// eslint-disable-next-line react/no-deprecated
import { render } from 'react-dom';
import SettingsLoader from '/imports/ui/components/settings-loader/component';
import ErrorBoundary from '/imports/ui/components/common/error-boundary/component';
import { ErrorScreen } from '/imports/ui/components/error-screen/component';
import PresenceManager from '/imports/ui/components/join-handler/presenceManager/component';
import LoadingScreenHOC from '/imports/ui/components/common/loading-screen/loading-screen-HOC/component';
import IntlLoaderContainer from '/imports/startup/client/intlLoader';
import LocatedErrorBoundary from '/imports/ui/components/common/error-boundary/located-error-boundary/component';
import CustomUsersSettings from '/imports/ui/components/join-handler/custom-users-settings/component';
import MeetingClient from '/client/meetingClient';
const STARTUP_CRASH_METADATA = { logCode: 'app_startup_crash', logMessage: 'Possible startup crash' };
const APP_CRASH_METADATA = { logCode: 'app_crash', logMessage: 'Possible app crash' };
/* eslint-disable */
if (
process.env.NODE_ENV === 'production'
// @ts-ignore
&& window.__REACT_DEVTOOLS_GLOBAL_HOOK__
) {
// @ts-ignore
for (const prop in window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
if (prop === 'renderers') {
// @ts-ignore
// prevents console error when dev tools try to iterate of renderers
window.__REACT_DEVTOOLS_GLOBAL_HOOK__[prop] = new Map();
continue;
}
// @ts-ignore
window.__REACT_DEVTOOLS_GLOBAL_HOOK__[prop] = typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__[prop] === 'function'
? Function.prototype
: null;
}
}
/* eslint-enable */
const Main: React.FC = () => {
return (
<SettingsLoader>
<ErrorBoundary
Fallback={ErrorScreen}
logMetadata={STARTUP_CRASH_METADATA}
isCritical
>
<LoadingScreenHOC>
<IntlLoaderContainer>
{/* from there the error messages are located */}
<LocatedErrorBoundary
Fallback={ErrorScreen}
logMetadata={APP_CRASH_METADATA}
isCritical
>
<ConnectionManager>
<PresenceManager>
<CustomUsersSettings>
<MeetingClient />
</CustomUsersSettings>
</PresenceManager>
</ConnectionManager>
</LocatedErrorBoundary>
</IntlLoaderContainer>
</LoadingScreenHOC>
</ErrorBoundary>
</SettingsLoader>
);
};
render(
<Main />,
document.getElementById('app'),
);