From e0344790e74837155b29d0f1772d53318a3edae7 Mon Sep 17 00:00:00 2001 From: Hubert Sosinski Date: Mon, 25 May 2026 11:55:48 +0200 Subject: [PATCH 1/2] Report lazy modal chunk failures to Sentry as warnings --- src/components/LazyModalSlot.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/LazyModalSlot.tsx b/src/components/LazyModalSlot.tsx index c28aadcc4d8e..cf39a102b52e 100644 --- a/src/components/LazyModalSlot.tsx +++ b/src/components/LazyModalSlot.tsx @@ -1,9 +1,23 @@ +import * as Sentry from '@sentry/react-native'; import React, {Suspense} from 'react'; import {ErrorBoundary as ReactErrorBoundary} from 'react-error-boundary'; import Log from '@libs/Log'; -const logModalChunkFailure = (error: Error, info: {componentStack?: string | null}) => - Log.alert(`[GlobalModals] lazy chunk failure - ${error.message}`, {componentStack: info.componentStack ?? undefined}, false); +const logModalChunkFailure = (error: Error, info: {componentStack?: string | null}) => { + const componentStack = info.componentStack ?? undefined; + Log.alert(`[GlobalModals] lazy chunk failure - ${error.message}`, {componentStack}, false); + + /* Lazy-chunk failures are silent ({fallback: null}) and largely environmental + * (deploy churn, ad-blockers, flaky networks), so report as warning with a + * fixed fingerprint to keep them in one Sentry issue instead of fragmenting + * per slot/chunk. */ + Sentry.captureException(error, { + level: 'warning', + tags: {context: 'lazy-modal-chunk'}, + fingerprint: ['lazy-modal-chunk-failure'], + extra: {componentStack}, + }); +}; /** * Wraps a lazy-loaded child in its own ErrorBoundary + Suspense pair so a chunk-load failure From 0409654eb292c32edc7e3a4ea30a7ccfeac20b41 Mon Sep 17 00:00:00 2001 From: Hubert Sosinski Date: Mon, 25 May 2026 12:41:19 +0200 Subject: [PATCH 2/2] Discriminate chunk-load failures from render errors in LazyModalSlot --- src/components/LazyModalSlot.tsx | 33 ++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/components/LazyModalSlot.tsx b/src/components/LazyModalSlot.tsx index cf39a102b52e..7c60f6b8abc9 100644 --- a/src/components/LazyModalSlot.tsx +++ b/src/components/LazyModalSlot.tsx @@ -3,18 +3,31 @@ import React, {Suspense} from 'react'; import {ErrorBoundary as ReactErrorBoundary} from 'react-error-boundary'; import Log from '@libs/Log'; -const logModalChunkFailure = (error: Error, info: {componentStack?: string | null}) => { +const isChunkLoadError = (error: Error) => error.name === 'ChunkLoadError' || /Loading chunk \S+ failed/i.test(error.message); + +const logModalError = (error: Error, info: {componentStack?: string | null}) => { const componentStack = info.componentStack ?? undefined; - Log.alert(`[GlobalModals] lazy chunk failure - ${error.message}`, {componentStack}, false); - /* Lazy-chunk failures are silent ({fallback: null}) and largely environmental - * (deploy churn, ad-blockers, flaky networks), so report as warning with a - * fixed fingerprint to keep them in one Sentry issue instead of fragmenting - * per slot/chunk. */ + if (isChunkLoadError(error)) { + /* Chunk-load failures are silent ({fallback: null}) and largely environmental + * (deploy churn, ad-blockers, flaky networks), so report as warning with a + * fixed fingerprint to keep them in one Sentry issue instead of fragmenting + * per slot/chunk. */ + Log.alert(`[GlobalModals] lazy chunk failure - ${error.message}`, {componentStack}, false); + Sentry.captureException(error, { + level: 'warning', + tags: {context: 'lazy-modal-chunk'}, + fingerprint: ['lazy-modal-chunk-failure'], + extra: {componentStack}, + }); + return; + } + + // Render-phase error inside a lazy modal — a real bug. Keep default error level + // and default (stack-based) fingerprint so it surfaces alongside other crashes. + Log.alert(`[GlobalModals] modal render error - ${error.message}`, {componentStack}, false); Sentry.captureException(error, { - level: 'warning', - tags: {context: 'lazy-modal-chunk'}, - fingerprint: ['lazy-modal-chunk-failure'], + tags: {context: 'lazy-modal-render-error'}, extra: {componentStack}, }); }; @@ -27,7 +40,7 @@ function LazyModalSlot({children}: {children: React.ReactNode}) { return ( {children}