GeezerVison is showing github.com — Opencode race condition with installDependencies() · Issue #4137 · anomalyco/opencode
Opencode race condition with installDependencies() #4137
Labels
bugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentui Description
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/[email protected] 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:
- First bun add attempt fails (exits immediately at +8ms)
- Second bun add attempt succeeds (takes 423ms, completes at +417ms)
- Plugin loading starts at +4ms (only 4ms after initial failure!)
- Import fails at +11ms (7ms later)
The Problem:
The successful bun add at +417ms is too late - plugin loading already started at +4ms.
- Concurrent execution - installDependencies() not awaited
- Plugin loader doesn't wait - Starts importing before dependencies installed
- Race condition - Even when install succeeds, timing is unpredictable
OpenCode version
1.0.46
Activity
github-actions commented on Nov 9, 2025
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.
wolfie82 commented on Nov 9, 2025
ContributorAuthor
More actions
I didn't mention I was running on WSL, which is solved by using WSL 2.0
oven-sh/bun#20724
Metadata
Metadata
bugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentui Development
No branches or pull requestsIssue actions