Skip to content

Commit 80d082d

Browse files
iHiDclaude
andcommitted
Handle chunk load errors at source to prevent Sentry propagation
After all retries are exhausted, if the error is a chunk load error, reload the page directly instead of throwing. This ensures the error never reaches Sentry.captureException via ErrorBoundary handlers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 573c9a6 commit 80d082d

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

app/javascript/utils/lazy-with-retry.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import React from 'react'
2+
import {
3+
isChunkLoadError,
4+
safeReloadForChunkError,
5+
} from './chunk-load-error-handler'
26

37
const MAX_RETRIES = 3
48
const RETRY_DELAY_MS = 1000
@@ -18,7 +22,13 @@ function retryImport<T extends React.ComponentType<any>>(
1822
retriesLeft = MAX_RETRIES
1923
): Promise<{ default: T }> {
2024
return factory().catch((error) => {
21-
if (retriesLeft <= 0) throw error
25+
if (retriesLeft <= 0) {
26+
if (isChunkLoadError(error)) {
27+
safeReloadForChunkError()
28+
return new Promise<{ default: T }>(() => {})
29+
}
30+
throw error
31+
}
2232

2333
return new Promise<{ default: T }>((resolve) =>
2434
setTimeout(

0 commit comments

Comments
 (0)