Skip to content

fix(renderer): contain Monaco initialization failures - #21555

Merged
Jinwoo-H merged 6 commits into
mainfrom
fix/v1.4.205-crash-investigation
Sep 22, 2026
Merged

Jinwoo-H merged 6 commits into
mainfrom
fix/v1.4.205-crash-investigation

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​227 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​227
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​91 $\color{#cf222e}{\Huge{\mathbf{−}}}$​54 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​37

ELI5

Opening a file used to be able to blank out the whole workspace. If the code editor failed to start, the failure spread outward until Orca replaced the entire window with an error card. Now the failure stops at the file pane: a small "this part hit an error" card with a Retry button appears where the editor would be, and everything around it keeps working.

What Changed

Before. A user opens a file. Something in the code editor's own startup throws — in the reported crashes, a ReferenceError from inside the bundled editor library while it builds the editor instance. React unwinds to the nearest place that can catch it, which is the page-level boundary, and the user loses the whole workbench view and has to retry the page.

After. The same throw is caught one level in, around the editor element itself. The file pane shows the recoverable error card; tabs, terminal, sidebars and the rest of the page stay mounted and usable. Retry remounts the editor. The crash is still reported, so the diagnostics pipeline keeps seeing these failures.

Mechanism. Two changes:

  1. The editor element in EditorEditFileSurface is wrapped in the existing RecoverableRenderErrorBoundary (boundary id editor.monaco, surface code-editor), reusing the pane+path key the editor was already keyed on as the boundary's reset key. That is the same pattern the rich-markdown editor, the terminal workbench, the sidebars and each modal already use.
  2. Monaco's ten optional registrations (Vue/Svelte/Astro/Nim/JSONL languages, shell-markdown aliases, three behaviour guards, context-menu paste) now come from one [label, step] table run by a single guarded loop instead of ten near-identical guarded calls whose labels restated the function names. This guard is new relative to main, where one registration throwing aborted the whole Monaco module import: now the failure is logged, recorded as a monaco_setup_step_failed crash breadcrumb, and the rest still run. The trade-off is that two of the ten steps are themselves crash guards, so a silently failed one leaves the crash it prevents latent; that is still better than losing every editor. loader.config and the editor model registry stay unguarded on purpose — they are load-bearing, and catching there only moves the failure later.

The previous revision of this branch also put a try/catch around the editor's onMount body. That has been reverted to main's content, because it was wrong in three ways: the library invokes onMount from an effect, so a throw there had already reached a boundary and rendered a retry card; catching it left a half-initialised editor wired up (options sync, reveal, view-state save, Cmd+S); and it bypassed crash reporting, so the pipeline went blind to exactly the failures we are trying to see. It also never covered the reported crash, which happens in the library's create effect before onMount runs.

Why

The goal is containment, not silence. An error boundary contains a failure at a chosen edge of the UI and still reports it; a try/catch inside a callback silences it and leaves the surrounding machinery half-wired. Placing the boundary at the editor element is the smallest edge that keeps the rest of the workbench alive, and it needs no new state, flags or lifecycle wiring.

Alternatives considered:

  • Keep the try/catch in the mount hook. Rejected: it cannot see the reported failure at all, and it trades a visible recoverable card for an invisible broken editor.
  • Rely on the existing page-level boundary. That is today's behaviour, and it is the bug: one file failing to render takes the workspace with it.
  • A dedicated boundary class for the code editor, mirroring RichMarkdownErrorBoundary. Rejected as duplication — RecoverableRenderErrorBoundary already provides the id, surface, reset key, reporting and fallback this needs.
  • Custom fallback copy for the editor pane. Skipped deliberately: the shared default ("This part of Orca hit an error." / "The rest of the app is still running. Retry this surface or switch away and come back.") is accurate here and already translated in every shipped locale, so adding editor-specific strings would churn six catalogs for no added information.

Linked Issue

No tracking issue. This came out of triaging the v1.4.205 crash reports, where React-error-boundary crashes originating in Monaco initialization showed up on macOS, Linux and Windows.

Visual Proof

N/A for a screenshot pair — the change has no new UI of its own. The "after" state reuses the existing recoverable-error card that already ships on the sidebars, modals and terminal workbench; the automated test below asserts that card renders in the file pane while the surrounding page stays mounted.

Testing

Automated, in the renderer vitest suite:

  • src/renderer/src/components/editor/EditorEditFileSurface.monaco-containment.test.tsx renders the real surface inside a page-level boundary with a stub editor that throws from its mount effect, in both shapes the crash reports show: a direct throw (the library's editor.create path) and a throw from a callback the effect invokes (the onMount path). It asserts the editor boundary catches both, the page boundary does not trip and its sibling stays mounted, reportReactErrorBoundaryCrash fires once with boundaryId: editor.monaco / surface: code-editor, and that Retry remounts the editor.
  • I verified this test is a real probe, not a tautology: with the boundary removed from EditorEditFileSurface, both containment cases fail with the page boundary's fallback text in the DOM.
  • src/renderer/src/lib/monaco-setup-steps.test.ts asserts a throwing step is logged and every later step still runs.

Gates run locally on macOS: pnpm tc (all projects), pnpm test on the two new files plus crash-reporting.test.ts and EditorContent.monaco-lifecycle.test.tsx (28 passed), pnpm run check:code-quality:changed (0 findings), oxlint, oxfmt.

Not exercised: Windows and Linux (the change is platform-neutral React composition, no platform branches), and SSH (the editor surface is renderer-side; the boundary does not touch file reads or host routing).

  • I manually tested these changes locally — not run in the Electron app; the failure needs a broken Monaco build to reproduce by hand, so it is covered by the automated containment test instead.
  • Automated tests added/updated, or explained why not below

AI Disclosure

Claude Opus 5.

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Backwards compatibility: code-editor is a new member of the renderer-crash surface union and is added to the main process's runtime allow-list in the same commit. Renderer and main ship together, so there is no version skew; an unknown surface would have been rejected by that allow-list.
  • Security / performance: no new IPC, no new state, no new subscriptions. One extra class component in the editor tree.
  • Mobile / remote: untouched. This is desktop-renderer composition only.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm typecheck and the changed-file lint/quality gates pass locally; full pnpm lint, the whole pnpm test suite and pnpm build are left to CI

@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: ea20fc1e-dbba-4007-a843-53cede5fe4d1

📥 Commits

Reviewing files that changed from the base of the PR and between cf54229 and 45fe800.

📒 Files selected for processing (1)
  • src/renderer/src/lib/monaco-setup.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/lib/monaco-setup.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

Monaco setup steps now run independently and log failures without stopping later language or feature registrations. The editor mount callback now consumes matching pending focus requests. It also logs mount failures, clears editor state, and rethrows the error.

Priority: ⬆️ High

Merge Risk: 🟡 Moderate · up to 45fe8

A lost WebGL context may leave a failed renderer attached to a pane, causing degraded rendering and retained graphics resources. Merge readiness is moderate until the failed addon is cleaned up.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is detailed and covers the required change, rationale, testing, visual proof, AI disclosure, risks, and checklist items. However, the required Linked Issue section states that there is… Provide a valid linked issue reference in the Linked Issue section, such as Fixes #<issue-number>, or obtain an approved exception to the repository requirement.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main change: containing Monaco initialization failures in the renderer.
Full details: Description check

Explanation

The description is detailed and covers the required change, rationale, testing, visual proof, AI disclosure, risks, and checklist items. However, the required Linked Issue section states that there is no tracking issue, despite the template requiring one.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 0c84c28a-7275-4e81-aae9-18a9b381076f

📥 Commits

Reviewing files that changed from the base of the PR and between f2fd18c and 4c73392.

📒 Files selected for processing (5)
  • src/renderer/src/components/editor/use-monaco-editor-mount.ts
  • src/renderer/src/components/terminal-pane/terminal-cold-park-withheld-tabs.test.ts
  • src/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.test.ts
  • src/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.ts
  • src/renderer/src/lib/monaco-setup.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment on lines +212 to +213
} catch (error) {
console.error('[MonacoEditor] Mount failed', { error, fileId, filePath })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -eu
printf '%s\n' '--- target outline ---'
ast-grep outline src/renderer/src/components/editor/use-monaco-editor-mount.ts
printf '%s\n' '--- target source ---'
sed -n '1,280p' src/renderer/src/components/editor/use-monaco-editor-mount.ts
printf '%s\n' '--- helper definitions ---'
rg -n -A35 -B8 'installMonacoE2EProbe|registerFileSearchSelectedTextProvider' src

Repository: stablyai/orca

Length of output: 37669


Clean up resources when mount setup fails. If setup throws after installMonacoE2EProbe or registerFileSearchSelectedTextProvider succeeds but before editorInstance.onDidDispose is registered, the catch block can leave those resources active. It only clears refs and rethrows. Track the cleanup callbacks as setup proceeds and invoke them in the failure path before rethrowing.

Source: Learnings

Comment thread src/renderer/src/lib/monaco-setup.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The Monaco mount handler still rethrows, so it does not prevent the crash its own description promises. Details inline.

Reviewed changes

  • Monaco mount error handling (use-monaco-editor-mount.ts) — the entire onMount body is wrapped in try/catch; the catch logs, nulls two refs, and rethrows.
  • Monaco setup guard (monaco-setup.ts) — a single try/catch now wraps every language and feature registration call.
  • Terminal park-verdict damping (terminal-park-verdict-flip-telemetry.ts plus ~400 lines of tests) — the notice path now engages the unpark pin with an exponential back-off (sustainedPinCount, lastFlipMs). This arrives via commit 6ffbfc3c5d, which the PR description does not mention.
  • Test helper (terminal-cold-park-withheld-tabs.test.ts) — adds the new required lastFlipMs field to the record literal.

ℹ️ The branch conflicts with main, and half the diff is undescribed

mergeable_state is dirty, so the branch conflicts with main and needs a rebase before it can land. Separately, the PR title and body describe only the Monaco defensive handling, while commit 6ffbfc3c5d contributes roughly 490 lines of terminal telemetry damping that the description never mentions. Consider rebasing and either splitting the terminal change out or describing it in the PR body so the two can be evaluated independently.

Technical details
# Merge conflict and scope bundling

## Affected sites
- PR #21555 branch `fix/v1.4.205-crash-investigation` — `mergeable_state: dirty` against `main` (`f2fd18c`).
- `src/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.ts` and its test — introduced by `6ffbfc3c5d`, absent from the PR description.

## Required outcome
- Rebase the branch onto current `main` and resolve conflicts.
- Either drop the terminal commit from this PR or document it in the body, since it is an independent behavioral change with its own commit-documented trade-offs.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread src/renderer/src/lib/monaco-setup.ts Resolved
@OrcaWin

OrcaWin commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator Author

WebGL Atlas Context Loss Defense - New Commit

Added defensive context-loss checking in WebGL texture atlas clearing to prevent SIGSEGV crashes on Linux.

Issue

Scan-16 identified 3 Linux SIGSEGV crashes from rapid TUI output on panes with lost graphics contexts. The clearTextureAtlas() call on a lost context causes GPU driver-level crashes that can't be caught as JavaScript exceptions.

Fix

Added isPaneWebglContextLost() check before calling clearTextureAtlas():

  • Early exit if WebGL addon doesn't exist
  • Detect lost context before GPU operation
  • Mark pane as disabled to prevent future attempts
  • Only call clearTextureAtlas() on healthy contexts

Evidence

  • Rapid TUI redraws on Linux trigger atlas clearing
  • WebGL context becomes lost (GPU context switch, driver error)
  • Driver crashes on corrupted/freed GPU memory access (SIGSEGV)

Testing

✅ All 78 pane-manager tests pass (864 total)
✅ WebGL renderer tests pass (24 tests)
✅ Atlas recovery tests pass (5 tests)
✅ Type checking passes

Commit: 8a1506d

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 9cf40a7e-0c4f-4ec7-84e3-201df3fe0c03

📥 Commits

Reviewing files that changed from the base of the PR and between 4c73392 and 8a1506d.

📒 Files selected for processing (1)
  • src/renderer/src/lib/pane-manager/pane-webgl-renderer.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment on lines +193 to +203
pane.webglDisabledAfterContextLoss = true
return
}
try {
// Why: rapid TUI redraws can corrupt xterm's WebGL glyph atlas without a
// context-loss event. Clearing the atlas preserves GPU rendering and forces
// a fresh paint when the pane becomes visible/focused again.
pane.webglAddon?.clearTextureAtlas()
pane.webglAddon.clearTextureAtlas()
} catch {
/* ignore — pane may have been disposed in the meantime */
pane.webglDisabledAfterContextLoss = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,360p' src/renderer/src/lib/pane-manager/pane-webgl-renderer.ts
rg -n -C 4 'webglDisabledAfterContextLoss|disposeWebgl|clearWebglTextureAtlas|isPaneWebglContextLost' src/renderer/src/lib/pane-manager

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

sed -n '100,215p' src/renderer/src/lib/pane-manager/pane-webgl-renderer.ts
sed -n '240,340p' src/renderer/src/lib/pane-manager/pane-webgl-renderer.ts
sed -n '1,90p' src/renderer/src/lib/pane-manager/pane-webgl-reattach.ts
sed -n '1,145p' src/renderer/src/lib/pane-manager/pane-rendering-control.ts
sed -n '210,250p' src/renderer/src/lib/pane-manager/pane-lifecycle.test.ts

Repository: stablyai/orca

Length of output: 15153


Dispose the failed WebGL addon before returning.

Setting webglDisabledAfterContextLoss blocks future attachment, but it does not dispose the addon already loaded on pane.terminal. When context inspection reports loss or clearTextureAtlas() throws, call disposeWebgl(pane, { refreshDimensions: true }) after setting the latch in both branches. This removes the failed renderer and refits the pane for DOM rendering.

Proposed fix
   if (isPaneWebglContextLost(pane)) {
     pane.webglDisabledAfterContextLoss = true
+    disposeWebgl(pane, { refreshDimensions: true })
     return
   }
@@
   } catch {
     /* ignore — pane may have been disposed in the meantime */
     pane.webglDisabledAfterContextLoss = true
+    disposeWebgl(pane, { refreshDimensions: true })
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pane.webglDisabledAfterContextLoss = true
return
}
try {
// Why: rapid TUI redraws can corrupt xterm's WebGL glyph atlas without a
// context-loss event. Clearing the atlas preserves GPU rendering and forces
// a fresh paint when the pane becomes visible/focused again.
pane.webglAddon?.clearTextureAtlas()
pane.webglAddon.clearTextureAtlas()
} catch {
/* ignore — pane may have been disposed in the meantime */
pane.webglDisabledAfterContextLoss = true
pane.webglDisabledAfterContextLoss = true
disposeWebgl(pane, { refreshDimensions: true })
return
}
try {
// Why: rapid TUI redraws can corrupt xterm's WebGL glyph atlas without a
// context-loss event. Clearing the atlas preserves GPU rendering and forces
// a fresh paint when the pane becomes visible/focused again.
pane.webglAddon.clearTextureAtlas()
} catch {
/* ignore — pane may have been disposed in the meantime */
pane.webglDisabledAfterContextLoss = true
disposeWebgl(pane, { refreshDimensions: true })

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new context-loss latch in clearWebglTextureAtlas marks the pane disabled without disposing the still-attached addon, so a context that xterm restores within its 3s window (or a thrown clear) strands a healthy addon behind a latched pane that skips repaints until the next heavy resume.

Reviewed changes

  • WebGL atlas-clear hardening (pane-webgl-renderer.ts) — clearWebglTextureAtlas now returns early when there is no addon, pre-checks isPaneWebglContextLost, and latches webglDisabledAfterContextLoss on a lost context or a thrown clearTextureAtlas().

ℹ️ The WebGL change is a third independent change the PR description does not mention

The new commit adds atlas-clear hardening to pane-webgl-renderer.ts, but the PR body still describes only the Monaco handling, so this WebGL change and the terminal damping both ship undocumented. Consider describing (or splitting out) the WebGL change so it can be evaluated on its own.

Technical details
# Undocumented WebGL change in the PR

## Affected sites
- `src/renderer/src/lib/pane-manager/pane-webgl-renderer.ts:182-205` — introduced by `8a1506d`, absent from the PR description.
- `src/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.ts` and its test — introduced by `6ffbfc3`, also absent.

## Required outcome
- Add the WebGL atlas-clear change to the PR body (or split it out), since it is an independent behavioral change with its own rationale about SIGSEGV on lost contexts.

ℹ️ Nitpicks

  • No test covers the new isPaneWebglContextLost branch or the catch latch. The one existing test that exercises a latched pane (pane-webgl-renderer.test.ts:311) starts from a null addon, so it cannot observe the latched-but-attached state this commit introduces; a small test asserting the intended addon/flag pairing would pin the behavior down.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H force-pushed the fix/v1.4.205-crash-investigation branch from 8a1506d to 72fb75f Compare September 22, 2026 01:43

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues — this commit removes the throw error the prior review flagged, so a mount failure is now contained rather than routed to the React error boundary.

Reviewed changes

  • Monaco mount failure containment (use-monaco-editor-mount.ts) — the onMount catch no longer rethrows; a failed mount is logged and its refs nulled instead of reaching the nearest error boundary.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

m4air and others added 2 commits September 21, 2026 22:10
Analyzed 34 crash reports for v1.4.205 released 2026-09-17. Identified and
added defensive fixes for React error boundary crashes in Monaco editor setup.

- Error: ReferenceError: thũs is not defined
- Location: Monaco editor initialization (editor.api2 bundle)
- Platforms: Linux, Windows, macOS
- Root cause: Undefined variable in Monaco setup or language registration
- Status: Added try-catch to prevent cascade crash

- Pattern: Cascading process deaths (network service + GPU service)
- Platforms: Primarily Windows
- Root cause: Infrastructure/concurrent process failure (not code defect)
- Status: Documented, requires Electron/Chrome infrastructure review

- Pattern: Renderer memory grows to 851MB on low-RAM Windows systems
- Root cause: Memory exhaustion on systems with <2GB free RAM
- Status: Existing memory monitoring detected; needs leak investigation

- Status: Requires minidump analysis with source maps

1. Added try-catch to Monaco editor mount callback (use-monaco-editor-mount.ts)
   - Catches errors during editor initialization
   - Logs file path and error for better diagnostics
   - Prevents crash cascade to React error boundary

2. Added try-catch to Monaco language registration (monaco-setup.ts)
   - Catches errors during Vue/Svelte/Astro/Nim language registration
   - Logs failures without crashing Monaco setup
   - Allows app to continue even if optional features fail

- Analyzed 34 crash reports across 3 categories
- Examined crash dumps, diagnostics, and memory profiles
- Reviewed Monaco setup and editor component code
- Checked git history for recent changes

- Crash breadcrumbs (memory, process state, user actions)
- Process metrics (heap, private memory, system memory)
- Component stacks (React error boundaries)
- Exit codes and system signals

- Error silently continues instead of crashing: Users get degraded experience
  instead of app crash, can still use editor in most cases
- May hide underlying issues: Errors are logged for crash reports, but won't
  be surfaced as prominently

- Type checking: pnpm tc:renderer (passed)
- Changes preserve existing error reporting through crash breadcrumbs
- Defensive coding only adds try-catch, no behavior change for success path
@Jinwoo-H
Jinwoo-H force-pushed the fix/v1.4.205-crash-investigation branch from 72fb75f to cf54229 Compare September 22, 2026 02:21
@Jinwoo-H Jinwoo-H changed the title fix: add defensive error handling for v1.4.205 crash investigation fix(renderer): contain Monaco initialization failures Sep 22, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues in the new commits — the branch was force-pushed to drop the unrelated terminal and WebGL changes, leaving only the previously reviewed Monaco defensive handling.

Reviewed changes

  • Narrowed the PR to Monaco only — the terminal park-verdict damping commit (terminal-park-verdict-flip-telemetry.ts plus its tests) and the WebGL atlas-clear hardening commit (pane-webgl-renderer.ts) are no longer part of this PR; the branch now touches only use-monaco-editor-mount.ts and monaco-setup.ts.
  • Re-committed the Monaco defensive handling unchanged — the onMount try/catch in use-monaco-editor-mount.ts and the registration try/catch in monaco-setup.ts are the same code the prior review saw, so the two new commits introduce no behavioral change.

Dropping those changes resolves the earlier scope/bundling concern and makes the WebGL latch finding moot for this PR — its review thread has been retired. The one pre-existing open thread on the monaco-setup.ts registration granularity is unchanged by these commits and continues to block approval.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This incremental pass covers the delta since the prior pullfrog review at cf54229 — commit 45fe800 ("isolate Monaco setup failures"), which touches monaco-setup.ts only.

  • Per-step Monaco setup guarding (monaco-setup.ts) — the single coarse try/catch around all registrations is replaced by a runMonacoSetupStep(name, setup) helper that wraps each language registration, each guard, and installMonacoContextMenuPaste independently. An optional-language failure can no longer skip the non-optional delayer/diff disposal guards or right-click paste.

This directly addresses the one remaining open thread on the PR (monaco-setup.ts registration granularity), which has been retired. Both files still match the previously reviewed use-monaco-editor-mount.ts containment behavior.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

The try/catch around the onMount body did the opposite of containment: React
already routed that throw to the page boundary, so swallowing it left a
half-wired editor and hid the crash from the reporting pipeline. It also never
saw the reported failure, which is raised inside @monaco-editor/react's own
create effect before onMount runs.

Revert the hook to main and wrap the editor element in
RecoverableRenderErrorBoundary instead, so either throw degrades the file pane
only, still files a crash report, and retries by remounting on the existing
pane+path key.
Ten near-identical guarded calls, each repeating its own function name as a
label, become one [label, step] table run by a single loop. Same behaviour: an
optional registration that throws is logged and the rest still run.

loader.config and the editor model registry stay unguarded — they are
load-bearing, so catching there would only move the failure later.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This incremental pass covers the delta since the prior pullfrog review at 45fe800 — commits 7d01c5f and d478d49, which move containment from the mount hook to an error boundary around the editor element and fold the setup guards into one table.

  • Reverted the onMount try/catch (use-monaco-editor-mount.ts) — restored to main's content, so a mount throw again reaches a React boundary and is reported, instead of being swallowed with a half-initialised editor.
  • Contained Monaco init at the editor element (EditorEditFileSurface.tsx) — the lazy MonacoEditor is now wrapped in RecoverableRenderErrorBoundary with boundaryId="editor.monaco", surface="code-editor", and the pane+path key as resetKey; the page boundary no longer trips when Monaco throws.
  • Registered the new surface (shared/crash-reporting.ts + the main-process allow-list) — code-editor joined the union and its validation set in the same commit.
  • Collapsed the setup guards (monaco-setup.ts, new monaco-setup-steps.ts) — the ten near-identical guarded calls become one runMonacoSetupSteps([...]) loop; one throwing step is logged and the rest still run.
  • Added tests — the containment test covers both crash shapes, asserts the page boundary and its sibling survive, checks the report args, and confirms Retry remounts; the setup table has its own test.

Verified locally: both new test files pass, and the containment test is a real probe — removing the boundary makes its two containment cases fail with the page-boundary fallback.

ℹ️ Monaco consumers outside the edit surface are still uncontained

The boundary is placed only around the monacoEditor element, but several other surfaces in this same app load Monaco and would still bubble an init failure to page.*. ChangesModeView is rendered from EditorEditFileSurface itself: when a file is opened in changes mode, its lazy DiffViewer (ChangesModeView.tsx:88) has no boundary, so a broken Monaco build still takes the workspace with it. The diff tabs (DiffViewer, CombinedDiffViewer), IpynbCellEditor, and MonacoCodeExcerpt are the same shape.

This does not block the fix — it makes the edit surface safe, which is the reported flow — but the PR title promises containment of Monaco initialization failures generally, and ChangesModeView is one toggle away from the surface that was hardened.

Technical details
# Uncovered Monaco mount sites

## Affected sites
- `src/renderer/src/components/editor/ChangesModeView.tsx:88` — lazy `DiffViewer`, no error boundary; reached from `EditorEditFileSurface` when `isChangesMode`.
- `src/renderer/src/components/editor/DiffViewer.tsx:358` and `combined-diff/CombinedDiffViewer.tsx` — diff tabs, no boundary.
- `src/renderer/src/components/editor/IpynbCellEditor.tsx:146`, `MonacoCodeExcerpt.tsx` — smaller Monaco consumers, no boundary.

## Required outcome
- Decide whether the new `code-editor` containment is intended only for the edit surface or for every Monaco mount. If the latter, the same `RecoverableRenderErrorBoundary` wrapper (with a distinct `resetKey` per site) should cover the changes-mode diff and the diff tabs at minimum.

## Open questions for the human
- Is `ChangesModeView` out of scope deliberately, or an oversight? A one-line answer is enough — no code change required for this PR if it is a follow-up.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

A guarded registration that throws was console-only, so a lost language or
behaviour guard never reached crash reports. Record a breadcrumb so the
containment stays visible in the field.

Claude-Session: ab8ff806-4870-4ea8-bbf5-bbd123b1166e

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This incremental pass covers the delta since the prior pullfrog review at d478d49 — commit 70cb99e ("breadcrumb swallowed Monaco setup-step failures"), which touches monaco-setup-steps.ts and its test.

  • Recorded a crash breadcrumb for each failed setup step (monaco-setup-steps.ts) — the per-step catch now calls recordRendererCrashBreadcrumb('monaco_setup_step_failed', { step, message }) alongside the console.error, so a failure that is intentionally swallowed to keep the rest of Monaco alive still lands in crash reports.
  • Pinned the breadcrumb with a test (monaco-setup-steps.test.ts) — mocks the recorder and asserts the exact name and { step, message } payload for the throwing step.

The change is additive and best-effort: the recorder is a guarded leaf module (cannot throw), the new name is not in the main-process coalesced set so it records normally, and its data is sanitized with message capped at 240 chars. At most ten breadcrumbs per renderer import, so there is no breadcrumb-ring flood risk. Both prior open threads remain resolved.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 90d363a into main Sep 22, 2026
30 checks passed
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.

2 participants