GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: wait for dependencies before loading custom tools and plugins by thdxr · Pull Request #12227 · anomalyco/opencode

Conversation

@thdxr

@thdxr thdxr commented Feb 5, 2026

Copy link
Copy Markdown
Member

Summary

Fixes a race condition where custom tools with external dependencies in their package.json would crash on import because dependencies weren't installed yet.

Problem

When a custom tool file had an import like:

import { say } from 'cowsay'

at the top level, and the tool directory had a package.json with cowsay as a dependency, the tool would crash with "Cannot find package 'cowsay'" because dependencies weren't installed before the module was imported.

Solution

  1. Config.state() now collects dependency installation promises in a deps array using iife()
  2. Added Config.waitForDependencies() to await all installations before proceeding
  3. ToolRegistry calls waitForDependencies() before loading custom tools (if tools exist)
  4. Plugin.list() calls waitForDependencies() before loading plugins (if plugins exist)

Changes

  • packages/opencode/src/config/config.ts: Track deps array and add wait function
  • packages/opencode/src/tool/registry.ts: Wait for deps before loading tools
  • packages/opencode/src/plugin/index.ts: Wait for deps before loading plugins
  • packages/opencode/test/tool/registry.test.ts: Added test verifying tools with external deps (cowsay) load successfully

Testing

Added a test that creates a tool with cowsay as a dependency and imports it at the top level. The test verifies the tool loads without crashing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@thdxr
fix: wait for dependencies before loading custom tools and plugins
85407d1
Fixes a race condition where custom tools with external dependencies in their
package.json would crash on import because dependencies weren't installed yet.

Changes:
- Config.state() now collects dependency installation promises in a deps array
- Added Config.waitForDependencies() to await all installations
- ToolRegistry calls waitForDependencies() before loading custom tools
- Plugin.list() calls waitForDependencies() before loading plugins
- Added test to verify tools with external deps (cowsay) load successfully
@github-actions github-actions Bot added the contributor label Feb 5, 2026
@thdxr
thdxr enabled auto-merge (squash) February 5, 2026 03:23
@thdxr
thdxr merged commit 556adad into dev Feb 5, 2026
6 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@thdxr
thdxr deleted the fix/tool-dependency-race-condition branch February 5, 2026 03:25
01luyicheng pushed a commit to 01luyicheng/opencode that referenced this pull request Feb 5, 2026
@thdxr 01luyicheng
fix: wait for dependencies before loading custom tools and plugins (a…
dccd00a
…nomalyco#12227)
This was referenced Feb 5, 2026
bug: tool.registry test fails on CI — custom tool import crashes registry when dependencies are missing #12269
Closed
fix: handle custom tool import failures gracefully in registry #12270
Closed
Colin4k1024 pushed a commit to Colin4k1024/opencode that referenced this pull request Feb 10, 2026
@thdxr @Colin4k1024
fix: wait for dependencies before loading custom tools and plugins (a…
2391cdd
…nomalyco#12227)
@adolago adolago mentioned this pull request Feb 14, 2026
[Opencode Sync] Core CLI: Tools, Skills, and MCP adolago/zee#313
Closed
3 tasks
schneiderlo pushed a commit to schneiderlo/opencode that referenced this pull request Feb 17, 2026
@thdxr @schneiderlo
fix: wait for dependencies before loading custom tools and plugins (a…
fb97f19
…nomalyco#12227)
@dgokeeffe dgokeeffe mentioned this pull request Feb 28, 2026
feat(opencode): Add Databricks provider support #7984
Closed
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request May 5, 2026
@thdxr
fix: wait for dependencies before loading custom tools and plugins (a…
10f837c
…nomalyco#12227)
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
@thdxr
fix: wait for dependencies before loading custom tools and plugins (a…
0963788
…nomalyco#12227)
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request Jun 14, 2026
@thdxr
fix: wait for dependencies before loading custom tools and plugins (a…
3f775a0
…nomalyco#12227)
MarsQiu007 referenced this pull request in MarsQiu007/openNovel Jul 31, 2026
@thdxr
fix: wait for dependencies before loading custom tools and plugins (#…
f424e3b
…12227)
meSingh pushed a commit to meSingh/opencode that referenced this pull request Sep 6, 2026
@thdxr
fix: wait for dependencies before loading custom tools and plugins (a…
2ea32fe
…nomalyco#12227)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@thdxr
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.