Skip to content

[Desktop macOS] Uncaught Exception: TypeError: Object has been destroyed (index.js:1283) - frequent crash #32923

Closed

Description

@nguyenngocduyphuc

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

  1. Open OpenCode Desktop on macOS
  2. Start a session, send a prompt
  3. Wait for response to complete (or interrupt it)
  4. Error dialog "A JavaScript error occurred in the main process" appears randomly
  5. 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

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)

  1. Clear ~/Library/Application Support/opencode/ and ~/Library/Caches/opencode/ — only reduces frequency
  2. Avoid interrupting the AI mid-stream
  3. Use the CLI version (opencode via brew install anomalyco/tap/opencode or curl -fsSL https://opencode.ai/install | bash) — bypasses Electron entirely

Activity

  1. SevereasPrangphit commented on Jun 24, 2026

    @SevereasPrangphit

    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.

  2. opencode-agent commented on Jul 20, 2026

    @opencode-agent
    Contributor

    Fixed by #37406.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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