Skip to content

Opencode race condition with installDependencies() #4137

Closed

Description

@wolfie82

Description

With recent versions of opencode >= 1.0.46, there appears to be a race condition when bun attempts to install packages from package.json in .opencode. We have some custom plugins that no longer function unless we manually do a npm install in the .opencode directory.

Issue:

18:52:01 +8ms - bun add fails (error code 1) - "An unknown error occurred (Unexpected)"
18:52:01 +417ms - bun add succeeds (code 0) - "@opencode-ai/plugin@1.0.40 installed"
18:52:01 +4ms - Plugin loading starts (dynamic-context-loader.ts)
18:52:01 +11ms - ERROR: Cannot find module '@opencode-ai/plugin'

Timeline Analysis:

  1. First bun add attempt fails (exits immediately at +8ms)
  2. Second bun add attempt succeeds (takes 423ms, completes at +417ms)
  3. Plugin loading starts at +4ms (only 4ms after initial failure!)
  4. Import fails at +11ms (7ms later)

The Problem:

The successful bun add at +417ms is too late - plugin loading already started at +4ms.

  1. Concurrent execution - installDependencies() not awaited
  2. Plugin loader doesn't wait - Starts importing before dependencies installed
  3. Race condition - Even when install succeeds, timing is unpredictable

OpenCode version

1.0.46

Activity

  1. github-actions commented on Nov 9, 2025

    @github-actions
    Contributor

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

    Feel free to ignore if none of these address your specific race condition case.

  2. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Nov 9, 2025
  3. wolfie82 commented on Nov 9, 2025

    @wolfie82
    ContributorAuthor

    I didn't mention I was running on WSL, which is solved by using WSL 2.0

    oven-sh/bun#20724

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions