Skip to content

Keep pages usable after lazy chunk reload failures - #6206

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/fix-lazy-import-reload-crash
Jun 23, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/fix-lazy-import-reload-crash

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

Summary

Keeps Orca usable when a lazy-loaded renderer chunk still fails after the one guarded reload recovery has already been attempted.

  • Splits lazy chunk reload guard state into not-attempted, attempted, and unavailable so blocked storage/no-window paths keep normal crash reporting.
  • Wraps only known post-reload dynamic import/chunk load failures in a narrow LazyChunkLoadError.
  • Lets RecoverableRenderErrorBoundary render the existing fallback while suppressing crash-report creation only for that exhausted lazy-load sentinel.
  • Keeps ordinary render errors and bare lazy module parse/evaluation errors reportable.
  • Removes an unnecessary exhaustive-switch default that blocked the full lint gate.

BYL Pipeline

Design:

  • Wrote scratch design doc: tmp/lazy-import-reload-containment-design.md (not included in the product diff).
  • Scoped to report eb15c957-0432-4107-b7c3-5cf7a77d9ec3, distinct from PR #6189.
  • Covered cross-platform, web, and SSH neutrality.

Design review:

  • Clean after guard-state correction.
  • Reviewer tightened the design so storage-unavailable/no-window paths preserve original errors rather than suppressing reports.

Implementation:

  • Implemented the reviewed design with focused lazy-loader and boundary changes.
  • Added deterministic tests for retry/reload behavior, exhausted dynamic-import failures, storage/no-window fail-closed behavior, ordinary errors, and bare parse errors.
  • Added a React boundary repro for the macOS crash shape: guarded TypeError("Failed to fetch dynamically imported module: file://...") renders fallback without a crash report.

Completeness verification:

  • Verified complete against every design requirement.
  • Confirmed no max-lines disables and no product artifact references to private reference material.

Code review:

  • Round 1 found the lazy-failure classifier was too broad because bare Unexpected token parse errors could be suppressed.
  • Fixed by removing the generic parse-error match and adding tests that bare parse/evaluation errors remain reportable.
  • Round 2 clean from both reviewers.
  • Final review after lint-gate cleanup clean from both reviewers.

Validation:

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/lib/lazy-with-retry.test.ts src/renderer/src/components/error-boundaries/RecoverableRenderErrorBoundary.lazy-chunk.test.tsx passed: 2 files, 11 tests.
  • pnpm exec oxlint src/renderer/src/lib/lazy-with-retry.ts src/renderer/src/lib/lazy-with-retry.test.ts src/renderer/src/components/error-boundaries/RecoverableRenderErrorBoundary.tsx src/renderer/src/components/error-boundaries/RecoverableRenderErrorBoundary.lazy-chunk.test.tsx src/renderer/src/components/task-page-github-work-item-status.ts passed.
  • pnpm run lint:switch-exhaustiveness passed.
  • pnpm run lint passed.
  • pnpm run typecheck passed.
  • git diff --check passed.

Electron validation:

  • Launched this exact worktree with CDP and verified the app identity.
  • Simulated a post-reload lazy dynamic-import failure by setting orca:lazy-chunk-reload-attempted=1 and blocking a lazy chunk.
  • Observed the existing recoverable fallback while the workspace remained usable.
  • Verified crash APIs returned latestPending: null and latestReport: null.
  • Screenshot evidence captured locally at .playwright-cli/lazy-chunk-boundary-fallback.png (not committed).

Accepted gaps:

  • No live SSH session pass; the change is renderer-local and does not touch SSH/remoting behavior.
  • The full lint failure found during validation was outside the crash fix but was a tiny exhaustive-switch gate cleanup, included here so checks can pass.

Post-PR stabilization:

  • Pending automated review and PR checks.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 565ff71e-a3c2-402f-998b-fc7f99effa53

📥 Commits

Reviewing files that changed from the base of the PR and between 0880021 and 57a5c82.

📒 Files selected for processing (5)
  • src/renderer/src/components/error-boundaries/RecoverableRenderErrorBoundary.lazy-chunk.test.tsx
  • src/renderer/src/components/error-boundaries/RecoverableRenderErrorBoundary.tsx
  • src/renderer/src/components/task-page-github-work-item-status.ts
  • src/renderer/src/lib/lazy-with-retry.test.ts
  • src/renderer/src/lib/lazy-with-retry.ts
💤 Files with no reviewable changes (1)
  • src/renderer/src/components/task-page-github-work-item-status.ts

📝 Walkthrough

Walkthrough

lazy-with-retry.ts gains a ReloadGuardState tri-state type, exported LazyChunkLoadError class and isLazyChunkLoadError type guard, a refactored readChunkReloadGuardState/markChunkReloadAttempted pair that treats SSR and storage failures as guard-unavailable, and an isKnownDynamicImportFailure detector using error name and message regex. The loadLazyWithRetry reload branch now aborts if the guard write fails, and post-guard failures are wrapped as LazyChunkLoadError only when recognized as dynamic import failures. RecoverableRenderErrorBoundary.componentDidCatch adds an early return for isLazyChunkLoadError errors, skipping crash reporting. A new Vitest suite validates both the suppression and the ordinary-error reporting paths. Separately, the default branch is removed from the getTaskPageGitHubPRIconTone PR state switch.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: preventing Orca from becoming unusable after lazy chunk reload failures by introducing targeted error handling and recovery.
Description check ✅ Passed The description comprehensively covers all required template sections including Summary, Testing validation, AI Review Report details, and cross-platform considerations. However, Screenshots section is missing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@brennanb2025
brennanb2025 merged commit 4e63bb0 into main Jun 23, 2026
2 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/fix-lazy-import-reload-crash branch June 23, 2026 22:36
nwparker added a commit that referenced this pull request Aug 2, 2026
…g silently vetoed (#11929)

* fix(editor): stop filing crash reports for expected lazy-chunk swaps

RichMarkdownErrorBoundary reported every caught error as a react-error-boundary
crash, including the LazyChunkLoadError sentinel that lazy-with-retry throws
after it has already exhausted its retries and its one guarded reload. That
sentinel means "the chunk hash changed under a running window" (an app update),
which is deliberate graceful degradation, not a crash.

RecoverableRenderErrorBoundary already skips reporting it (#6206); this boundary
was never updated. Crash b860def2 is exactly that path: a lazy_chunk_reload
breadcrumb ("Unexpected token ':'") fires first, then the post-reload attempt
surfaces LazyChunkLoadError and files a report.

The fallback UI is unchanged, so the pane stays usable and offers retry.

* fix(editor): prove the lazy-chunk reload landed before suppressing crash reports

- lazy-with-retry: reload guard stores the requesting document's identity, so a
  vetoed reload() no longer reads as "recovery ran" (crash b860def2)
- lazy-with-retry: bound the post-reload suspension so a vetoed navigation
  surfaces the real error instead of hanging the pane on a spinner
- RichMarkdownErrorBoundary: contain the LazyChunkLoadError sentinel without a
  crash report, but record a lazy_chunk_boundary_degraded breadcrumb
- EditorContent: name the rich markdown chunk at the lazy call site

Co-authored-by: Orca <[email protected]>

* fix(editor): route lazy-chunk recovery reload through the intentional-restart path

Crash b860def2's recovery reload was requested and never landed: Terminal's
beforeunload handler preventDefault()s while any editor tab is dirty and Electron
cancels the navigation with no dialog, so chunk recovery could never run in the
common case. Take the updater's path instead — hot-exit backup, one synchronous
session checkpoint, restart latch — then reload.

- Reject on ORCA_RENDERER_UNLOAD_PREVENTED_EVENT instead of a blind, never-cleared
  10s timer; keep the timer only as a backstop.
- Record a lazy_chunk_reload_vetoed breadcrumb in the same tick as the report it
  now files, so the 30-entry ring cannot evict the evidence.
- Drop this document's own stale guard after a refused reload (capped in memory)
  so saving the blocking tab does not forfeit recovery for the session.
- Carry reloadKey on LazyChunkLoadError and the degraded breadcrumb.
- Move renderer-restart-preparation to src/shared: it is now a renderer/preload
  contract, and the composite web project cannot import preload runtime code.

Co-authored-by: Orca <[email protected]>

* fix(editor): clean up failed lazy chunk reload requests

* test(preload): exercise restart IPC registrations

---------

Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…g silently vetoed (stablyai#11929)

* fix(editor): stop filing crash reports for expected lazy-chunk swaps

RichMarkdownErrorBoundary reported every caught error as a react-error-boundary
crash, including the LazyChunkLoadError sentinel that lazy-with-retry throws
after it has already exhausted its retries and its one guarded reload. That
sentinel means "the chunk hash changed under a running window" (an app update),
which is deliberate graceful degradation, not a crash.

RecoverableRenderErrorBoundary already skips reporting it (stablyai#6206); this boundary
was never updated. Crash b860def2 is exactly that path: a lazy_chunk_reload
breadcrumb ("Unexpected token ':'") fires first, then the post-reload attempt
surfaces LazyChunkLoadError and files a report.

The fallback UI is unchanged, so the pane stays usable and offers retry.

* fix(editor): prove the lazy-chunk reload landed before suppressing crash reports

- lazy-with-retry: reload guard stores the requesting document's identity, so a
  vetoed reload() no longer reads as "recovery ran" (crash b860def2)
- lazy-with-retry: bound the post-reload suspension so a vetoed navigation
  surfaces the real error instead of hanging the pane on a spinner
- RichMarkdownErrorBoundary: contain the LazyChunkLoadError sentinel without a
  crash report, but record a lazy_chunk_boundary_degraded breadcrumb
- EditorContent: name the rich markdown chunk at the lazy call site

Co-authored-by: Orca <[email protected]>

* fix(editor): route lazy-chunk recovery reload through the intentional-restart path

Crash b860def2's recovery reload was requested and never landed: Terminal's
beforeunload handler preventDefault()s while any editor tab is dirty and Electron
cancels the navigation with no dialog, so chunk recovery could never run in the
common case. Take the updater's path instead — hot-exit backup, one synchronous
session checkpoint, restart latch — then reload.

- Reject on ORCA_RENDERER_UNLOAD_PREVENTED_EVENT instead of a blind, never-cleared
  10s timer; keep the timer only as a backstop.
- Record a lazy_chunk_reload_vetoed breadcrumb in the same tick as the report it
  now files, so the 30-entry ring cannot evict the evidence.
- Drop this document's own stale guard after a refused reload (capped in memory)
  so saving the blocking tab does not forfeit recovery for the session.
- Carry reloadKey on LazyChunkLoadError and the degraded breadcrumb.
- Move renderer-restart-preparation to src/shared: it is now a renderer/preload
  contract, and the composite web project cannot import preload runtime code.

Co-authored-by: Orca <[email protected]>

* fix(editor): clean up failed lazy chunk reload requests

* test(preload): exercise restart IPC registrations

---------

Co-authored-by: Orca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant