diff --git a/packages/twenty-front/src/modules/error-handler/components/AppErrorBoundary.tsx b/packages/twenty-front/src/modules/error-handler/components/AppErrorBoundary.tsx index d2d95b7e6..b3c81959a 100644 --- a/packages/twenty-front/src/modules/error-handler/components/AppErrorBoundary.tsx +++ b/packages/twenty-front/src/modules/error-handler/components/AppErrorBoundary.tsx @@ -1,5 +1,6 @@ import { AppErrorBoundaryEffect } from '@/error-handler/components/internal/AppErrorBoundaryEffect'; import { CustomError } from '@/error-handler/CustomError'; +import { checkIfItsAViteStaleChunkLazyLoadingError } from '@/error-handler/utils/checkIfItsAViteStaleChunkLazyLoadingError'; import { ErrorInfo, ReactNode } from 'react'; import { ErrorBoundary, FallbackProps } from 'react-error-boundary'; import { isDefined } from 'twenty-shared/utils'; @@ -36,6 +37,13 @@ export const AppErrorBoundary = ({ // eslint-disable-next-line no-console console.error('Failed to capture exception with Sentry:', sentryError); } + + const isViteStaleChunkLazyLoadingError = + checkIfItsAViteStaleChunkLazyLoadingError(error); + + if (isViteStaleChunkLazyLoadingError) { + window.location.reload(); + } }; const handleReset = () => { diff --git a/packages/twenty-front/src/modules/error-handler/utils/checkIfItsAViteStaleChunkLazyLoadingError.ts b/packages/twenty-front/src/modules/error-handler/utils/checkIfItsAViteStaleChunkLazyLoadingError.ts new file mode 100644 index 000000000..39dd2f8aa --- /dev/null +++ b/packages/twenty-front/src/modules/error-handler/utils/checkIfItsAViteStaleChunkLazyLoadingError.ts @@ -0,0 +1,3 @@ +export const checkIfItsAViteStaleChunkLazyLoadingError = (error: Error) => { + return error.message.includes('Failed to fetch dynamically imported module'); +};