Skip to content

Electron desktop app hangs on startup with large .gitignored projects #20977

@NishantGoswami-Mahakalp

Description

@NishantGoswami-Mahakalp

Description

The Electron desktop app becomes unresponsive on startup when a project with a large number of .gitignored files is in the saved project list. The sidecar process (opencode-cli serve) pegs at ~100% CPU indefinitely, making the app unusable.

Environment

  • opencode version: 1.3.13 (Electron AppImage, Linux x86_64)
  • OS: CachyOS (Arch-based), kernel 6.19.11-1-cachyos
  • Display: Wayland

Steps to Reproduce

  1. Open a project with a large number of files that are excluded via .gitignore (e.g. 213GB, ~514K files — most gitignored build artifacts/data)
  2. Close the app
  3. Reopen the app — the project is restored from saved state

Observed Behavior

  • Sidecar process (opencode-cli serve) immediately goes to ~98-100% CPU
  • CPU usage never settles (tested up to 45+ seconds)
  • The renderer process also spikes (~136% CPU initially)
  • The app window appears but is unresponsive
  • The sidecar health endpoint (/global/health) responds, so the HTTP server itself is running — the CPU is consumed by file watching/indexing

Expected Behavior

The experimental file watcher (OPENCODE_EXPERIMENTAL_FILEWATCHER=true, set by the Electron app) should respect .gitignore and skip ignored files/directories. Large gitignored directories (build outputs, data files, etc.) should not cause the sidecar to spin.

Root Cause Analysis

The Electron app sets OPENCODE_EXPERIMENTAL_FILEWATCHER=true in the sidecar environment. When the sidecar initializes a workspace for a project with hundreds of thousands of gitignored files, it appears to perform a naive recursive scan before (or without) applying .gitignore filters, causing an epoll busy-spin.

Evidence:

  • Running opencode-cli serve directly (without the experimental file watcher env var) uses 0% CPU at idle
  • Running with OPENCODE_EXPERIMENTAL_FILEWATCHER=true but without a client connecting also uses 0% CPU — the issue triggers when the renderer connects and the workspace is initialized
  • Clearing the project from the app's saved state (opencode.global.dat) resolves the issue immediately — sidecar drops to ~15% CPU on startup and settles to idle

Workaround

Clear the large project from ~/.config/ai.opencode.desktop/opencode.global.dat by resetting the server.projects field.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions