From f0decae9bf901c3f165bc21f4d8b1e259329ac6c Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Mon, 22 Sep 2025 11:34:08 +0700 Subject: [PATCH] Update global error boundary to add context for insertBefore error (#38854) * Update global error boundary to add context for insertBefore error * Reduce prominence of support button if running into google translate client crashess --- .../ui/GlobalErrorBoundaryState.tsx | 188 +++++++++++------- 1 file changed, 111 insertions(+), 77 deletions(-) diff --git a/apps/studio/components/ui/GlobalErrorBoundaryState.tsx b/apps/studio/components/ui/GlobalErrorBoundaryState.tsx index 92f916d196..2959826daa 100644 --- a/apps/studio/components/ui/GlobalErrorBoundaryState.tsx +++ b/apps/studio/components/ui/GlobalErrorBoundaryState.tsx @@ -5,14 +5,8 @@ import { useRouter } from 'next/router' import CopyButton from './CopyButton' import Image from 'next/image' -import { - AlertDescription_Shadcn_, - AlertTitle_Shadcn_, - Alert_Shadcn_, - Button, - WarningIcon, - cn, -} from 'ui' +import { Button, cn } from 'ui' +import { Admonition } from 'ui-patterns' import { InlineLinkClassName } from './InlineLink' export type FallbackProps = { @@ -29,6 +23,9 @@ export const GlobalErrorBoundaryState = ({ error, resetErrorBoundary }: Fallback const isRemoveChildError = checkIsError ? errorMessage.includes("Failed to execute 'removeChild' on 'Node'") : false + const isInsertBeforeError = checkIsError + ? errorMessage.includes("Failed to execute 'insertBefore' on 'Node'") + : false // Get Sentry issue ID from error if available const sentryIssueId = (!!error && typeof error === 'object' && (error as any).sentryId) ?? '' @@ -69,77 +66,103 @@ export const GlobalErrorBoundaryState = ({ error, resetErrorBoundary }: Fallback

{errorMessage}

- {isRemoveChildError ? ( - - - - This error might be caused by Google translate or third-party browser extensions - - - You may try to avoid using Google translate or disable certain browser extensions to - avoid running into the 'removeChild' on 'Node' error. - - - - - + {isRemoveChildError || isInsertBeforeError ? ( + +

+ Try to avoid using Google translate or disable certain browser extensions to avoid + running into the{' '} + + {isRemoveChildError + ? `'removeChild' on 'Node'` + : isInsertBeforeError + ? `'insertBefore' on 'Node'` + : ''} + {' '} + error.{' '} + window.location.reload()} + > + Refresh + {' '} + the browser to see if occurs again. +

+ +
) : ( - - We recommend trying the following: - -
    -
  • - window.location.reload()} - > - Refresh - {' '} - the page -
  • -
  • - router.push('/logout')} - > - Sign out - {' '} - and sign back in -
  • -
  • - - Clear your browser storage - {' '} - to clean potentially outdated data -
  • -
  • - Disable browser extensions that might modify page content (e.g., Google Translate) -
  • -
  • If the problem persists, please contact support for assistance
  • -
-
-
+ + + )} -
- +
+ {!isRemoveChildError && !isInsertBeforeError && ( + + )} + {/* [Joshen] For local and staging, allow us to escape the error boundary */} {/* We could actually investigate how to make this available on prod, but without being able to reliably test this, I'm not keen to do it now */} {process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod' ? ( @@ -151,6 +174,17 @@ export const GlobalErrorBoundaryState = ({ error, resetErrorBoundary }: Fallback Reload dashboard )} + + {(isRemoveChildError || isInsertBeforeError) && ( + + Still stuck? + + )}