Repository navigation
Description
Description
Uncaught Exception: TypeError: Object has been destroyed at BrowserWindow.<anonymous> (file:///Applications/OpenCode.app/Contents/Resources/app.asar/out/main/index.js:1283:76) at BrowserWindow.emit (node:events:508:28) at WebContents.<anonymous> (node:electron/js2c/browser_init:2:18879) at WebContents.emit (node:events:508:28) at file:///Applications/OpenCode.app/Contents/Resources/app.asar/out/main/index.js:2370:11 at <anonymous> at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
The error appears intermittently during/after a session completes on macOS. Same root cause as #30493, #29448, #30297, #30627.
Plugins
None / default
OpenCode version
v1.15.13 (Desktop)
Steps to reproduce
- Open OpenCode Desktop on macOS
- Start a session, send a prompt
- Wait for response to complete (or interrupt it)
- Error dialog "A JavaScript error occurred in the main process" appears randomly
- Status indicator turns red, app becomes unstable
Expected behavior
Desktop app should not throw uncaught exceptions in main process. WebContents callbacks should guard against destroyed BrowserWindow references.
Actual behavior
Uncaught TypeError: Object has been destroyed from BrowserWindow event handler (index.js:1283). The error indicates a WebContents event firing after the BrowserWindow has already been destroyed — classic Electron race condition between main and renderer processes.
Suggested fix (in out/main/index.js)
The handler at line 1283 should guard against destroyed windows:
if (this.isDestroyed()) return;…applied to the BrowserWindow event listener that calls into the destroyed object. Similar guard needed at the WebContents event chain (index.js:2370).
Operating System
macOS (Darwin) — but same bug also reported on Windows 11 (#30297) and Deepin Linux (#30627), so this is platform-agnostic.
Related issues
- Uncaught Exception: TypeError: Object has been destroyed in BrowserWindow #30493 (closed - not planned) - same stack, line 1313
- Desktop: Uncaught TypeError: Object has been destroyed in main process (index.js:679) #29448 (closed - not planned) - same stack, line 679
- lo Error 0 A JavaScript error occurred in the main process #30297 (open) - Windows 11
- 桌面端最近总是会时不时弹出A JavaScript error occurred in the main process报错 #30627 (open) - Linux/Deepin
Closing those as "not planned" without a fix is frustrating for users — this is a stable, reproducible crash on the latest release and the workaround (downgrade / clear cache / use CLI) is not obvious to non-technical users. Please reconsider and either fix or document the workaround in the release notes.
Workarounds used (none fully resolve the issue)
- Clear
~/Library/Application Support/opencode/and~/Library/Caches/opencode/— only reduces frequency - Avoid interrupting the AI mid-stream
- Use the CLI version (
opencodeviabrew install anomalyco/tap/opencodeorcurl -fsSL https://opencode.ai/install | bash) — bypasses Electron entirely
Activity
SevereasPrangphit commentedon Jun 24, 2026
I have found a way to reliably reproduce this. Ask it to generate a code snippet and then try to use the copy button in the generated snippet. It throws the error.
opencode-agent commentedon Jul 20, 2026
Fixed by #37406.