Skip to content

Plugin loading intermittently hangs when .git directory exists (Windows) #25668

Closed as not planned

Description

@Alfroul

Bug Description

When starting opencode in a directory that contains a .git folder, the plugin loading phase intermittently hangs indefinitely. The TUI shows "Loading plugins..." and becomes completely unresponsive (Ctrl+C doesn't work). This happens ~80% of the time in git-tracked project directories.

Reproduction Steps

  1. Install oh-my-openagent plugin (a 130K-line bundled JS module)
  2. Add to opencode.json: "plugin": ["oh-my-openagent"]
  3. Start opencode in any directory with a .git folder
  4. Observe: TUI shows "Loading plugins..." and hangs

Key Findings

  • Without .git in the working directory -> always starts successfully
  • Without any plugin configured -> always starts successfully (even with .git)
  • Both .git + plugin are required to trigger the hang
  • When it hangs, plugin JS code never begins executing - a console.error placed at the very first line of the module (before any other code) does not produce output
  • The hang happens at the await import(entry) stage in the plugin loader
  • When it does succeed, the full plugin loads normally with no issues

Environment

  • OS: Windows 11 (build 26200)
  • opencode: v1.14.33 (Bun-compiled binary)
  • Embedded Bun: v1.3.13
  • Plugin: oh-my-openagent v3.17.5 (~3.8MB bundled dist/index.js, 130K lines)
  • Git: v2.x (even a tiny 3-commit, 0.07MB repo triggers it)

What We Tried

Attempt Result
Set OMO_DISABLE_POSTHOG=true No effect (PostHog already disabled in code path)
Hardcoded return NO_OP_POSTHOG in plugin No effect - JS never executes
Changed plugin spec to absolute file path Slight improvement but still ~80% failure rate
Changed plugin spec to file:// URL Same failure rate
Created node_modules junction in project dir No effect
Cleaned SQLite database (177MB -> sessions removed) No effect
Checkpointed and VACUUMed WAL (174MB) No effect
Renamed .git to _git_hidden 100% success rate
Removed plugin from config 100% success rate

Root Cause Hypothesis

There appears to be a race condition in opencode's Bun runtime during plugin loading. When .git is present, opencode performs additional initialization (git status, project detection, session loading from SQLite) concurrently with the await import() of the plugin module. The combination of these concurrent operations causes the Bun runtime to deadlock or stall intermittently.

The fact that the JS module's top-level code never executes when hung suggests the issue is in the Bun import/evaluation pipeline itself, not in the plugin's JavaScript code.

Workaround

Open multiple terminal windows - one will eventually succeed. Alternatively, start opencode in a non-git directory first, then navigate to the project.

Activity

  1. github-actions commented on May 4, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is distinct (e.g. you are on a newer version where those are supposedly fixed, or the root cause differs), please add a note clarifying how this differs from the above.

  2. Alfroul commented on May 4, 2026

    @Alfroul
    Author

    Update: Root Cause Identified

    This issue is closely related to #25022. After extensive debugging, we traced the hang to the same root cause:

    The hang occurs in Project.fromDirectory(), not in the plugin loading itself. The UI shows "Loading plugins..." but the actual blocker is earlier — git subprocess calls during project directory initialization.

    Evidence matching #25022

    1. Our debug console.error at the very first line of the plugin module never produced output when hung → the Bun runtime never reached import() of the plugin
    2. Renaming .git → 100% success rate (no git subprocess calls needed)
    3. Removing the plugin from config → 100% success rate (no plugin loading means faster startup, so Project.fromDirectory() likely completes before the UI checks ready state)
    4. The intermittent nature (~80% failure) matches subprocess timing variability on Windows

    Additional context from our debugging

    • The issue occurs on regular git repos too, not just linked worktrees
    • Even a tiny 3-commit, 0.07MB .git repo triggers it
    • SQLite database size (172MB) and WAL (174MB) did not affect the outcome
    • The embedded Bun version is 1.3.13

    Distinguishing factors

    Our issue differs from #25022 in that it occurs on standard git repositories (not linked worktrees), and the trigger is the combination of .git presence + large plugin loading happening concurrently with Project.fromDirectory().

    The fix described in #25022 (resolve worktree topology from on-disk metadata first, avoid git subprocesses) would likely resolve our case as well.

  3. ukind commented on May 8, 2026

    @ukind

    this bug is very frustrating

  4. Skypow2012 commented on Jun 30, 2026

    @Skypow2012

    I've encountered it too.

  5. github-actions commented on Aug 30, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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