From 9c334947cd52cde6aefcee28fc193bdbf716e016 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Thu, 6 Aug 2026 15:35:40 -0700 Subject: [PATCH] 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. --- .../RecoverableRenderErrorBoundary.tsx | 3 +-- .../lib/lazy-with-retry.never-landed-reload.test.ts | 13 +++++++++++++ src/renderer/src/lib/lazy-with-retry.ts | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/components/error-boundaries/RecoverableRenderErrorBoundary.tsx b/src/renderer/src/components/error-boundaries/RecoverableRenderErrorBoundary.tsx index 5bd350d0d4f..e4c03e96aa0 100644 --- a/src/renderer/src/components/error-boundaries/RecoverableRenderErrorBoundary.tsx +++ b/src/renderer/src/components/error-boundaries/RecoverableRenderErrorBoundary.tsx @@ -50,8 +50,7 @@ export class RecoverableRenderErrorBoundary extends React.Component { 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) + }) }) diff --git a/src/renderer/src/lib/lazy-with-retry.ts b/src/renderer/src/lib/lazy-with-retry.ts index 0ed7237d1f7..77650b67ded 100644 --- a/src/renderer/src/lib/lazy-with-retry.ts +++ b/src/renderer/src/lib/lazy-with-retry.ts @@ -228,7 +228,7 @@ export async function loadLazyWithRetry( // 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',