Skip to content

Desktop (macOS): renderer V8 OOM crash loop when pasting large JSON into composer (parsePromptInputV2Editor) #43935

Description

@praxstack

Environment

  • OpenCode Desktop 1.18.21 (auto-updated from 1.18.20 right before first crash), macOS arm64, Electron 42.3.3 / Chrome 148 / Node 24.15.0

Summary

Pasting a large nested JSON blob (~165 KB session-export) into the chat composer crashes the renderer with a V8 heap OOM abort (render-process-gone, reason: crashed, exitCode: 5). If the pasted payload persists in the composer's prompt-history store, every subsequent app launch re-feeds it through the same parser and the renderer OOMs again within ~17 s — an unbootable crash loop.

Evidence

Both Crashpad minidumps carry identical V8 OOM crash keys and JS stacks:

v8-oom-location: Ineffective mark-compacts near heap limit
#0 (anonymous)             oc://renderer/assets/main-DxX1DkV8.js:128219:89
#1 parsePromptInputV2Editor                              :128219:60
#2 PromptInputV2._el$6.$$input                           :127950:22
#3 handleNode                                            :1800:64
#4 eventHandler                                          :1821:12
#5 onPaste                                               :129485:66

GC log at death:
  3847.2 (3917.9) -> 3847.1 (3917.7) MB ... last resort; GC in old space requested
  MarkCompactCollector: young object promotion failed

Heap pinned at ~3.85 GB against V8's ~4 GB ceiling in both crashes:

  • Crash 1: paste at T+9 min → ~10 min of ResizeObserver/layout thrash → OOM.
  • Crash 2 (relaunch): renderer hit 3.85 GB within 17 s of process start, no user input — consistent with persisted prompt-history being re-parsed on boot.

Ruled out: server-side session data (largest session ≈ 2.4 MB total parts), localStorage/IndexedDB (<150 KB), GPU.

Workaround that unblocked the machine

Delete the oversized entry from the desktop KV store while the app is closed:

sqlite3 "$HOME/Library/Application Support/ai.opencode.desktop/drafts.sqlite" \
  "UPDATE document SET value='{\"entries\":[]}' WHERE key LIKE '%prompt-history%';"

(Back up the file first.) Renderer then boots and stays healthy.

Suggested fixes

  1. Size-clamp paste input in parsePromptInputV2Editor (reject or truncate above e.g. 1–2 MB with a toast instead of parsing).
  2. Cap per-entry size/count in persisted prompt-history; don't restore entries above the clamp on boot.
  3. Treat paste-path allocation failures as recoverable (fail soft) rather than letting V8 abort the process.

Happy to share the two .dmp files if useful (Crashpad shows them as pending upload).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions