Verify ordinary errors bypass lazy chunk containment

Add test ensuring module evaluation bugs still surface despite
never-landed reload attempts. Clarify containment scope: recovery
only applies to known dynamic-import failures, not ordinary errors.
This commit is contained in:
Jinjing
2026-08-06 15:35:40 -07:00
parent accda29f71
commit 9c334947cd
3 changed files with 15 additions and 3 deletions
@@ -50,8 +50,7 @@ export class RecoverableRenderErrorBoundary extends React.Component<Props, State
return
}
if (isLazyChunkLoadError(error)) {
// Contained by this fallback; lazy-with-retry already recorded the chunk
// error, its call site, and the recovery outcome as a breadcrumb.
// Contained by this fallback; recovery breadcrumbs live on the load path.
return
}
void reportReactErrorBoundaryCrash({
@@ -128,4 +128,17 @@ describe('loadLazyWithRetry when the recovery reload never lands', () => {
expect(isLazyChunkLoadError(await settled)).toBe(true)
expect(window.sessionStorage.getItem(RELOAD_GUARD_KEY)).toBeNull()
})
it('still surfaces ordinary evaluation bugs after a never-landed reload attempt', async () => {
const error = new Error('render bug from lazy module evaluation')
const settled = loadLazyWithRetry(() => Promise.reject(error), { retries: 0 }).catch(
(rejection: unknown) => rejection
)
await vi.advanceTimersByTimeAsync(0)
await vi.advanceTimersByTimeAsync(RELOAD_SETTLE_GRACE_MS + 1)
// Containment is only for known dynamic-import failures; real bugs must still report.
expect(await settled).toBe(error)
expect(isLazyChunkLoadError(error)).toBe(false)
})
})
+1 -1
View File
@@ -228,7 +228,7 @@ export async function loadLazyWithRetry<T extends AnyComponent>(
// A sibling failing under a pending reload must not clear the guard, and an
// unrelated failure must not clear a guard it did not set.
if (!reloadRequestInFlight && isKnownDynamicImportFailure(lastError)) {
// Record the veto beside the resulting report before the ring can evict it.
// Record the veto before the ring can evict it; the failure is then contained.
clearChunkReloadGuard()
recordReloadBreadcrumb(
'lazy_chunk_reload_vetoed',