Skip to content

Conversation

@elithrar
Copy link
Contributor

@elithrar elithrar commented Jan 4, 2026

Fixes an issue where custom tools fail to load with "Cannot find module '@opencode-ai/plugin'" errors due to a tool loading vs. dependency installation "race".

This builds on #6302 by ensuring dependency installation completes before attempting to load custom tools that depend on those packages without impacting OpenCode startup time - e.g. we don't block app startup, just tool loading (which is already on-demand).

notably, this implementation ensures that tools wait only for their own directory's dependencies (minimal blocking).

problem: After #6302, OpenCode runs bun install for each config directory to install dependencies. However, if node_modules already exists, the installation runs asynchronously in the background without waiting. When custom tools are loaded immediately after, they fail to import @opencode-ai/plugin or other dependencies because the install hasn't finished yet.

fix: Track the install promise for each config directory and await it before loading tools from that directory:

  • Config directories start installing dependencies in parallel (non-blocking)
  • When the tool registry loads tools from a directory, it awaits that directory's install promise
  • This ensures tools only import after their dependencies are ready

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant