fix(plugin): skip non-function exports in getLegacyPlugins - #1944
Open
Cipher208 wants to merge 5 commits into
Open
fix(plugin): skip non-function exports in getLegacyPlugins#1944Cipher208 wants to merge 5 commits into
Cipher208 wants to merge 5 commits into
Conversation
External plugins fail to load because getLegacyPlugins throws TypeError when encountering any export that is not a function and doesn't have a 'server' property (e.g. constants, config objects, type re-exports). This causes the entire plugin to be silently skipped — the error is caught in applyPlugin's Effect.catch and logged, but hooks are never registered. Fix: change 'throw' to 'continue' so non-plugin exports are silently skipped, matching the behavior of getServerPlugin which already returns undefined for non-plugin values. This fixes the issue where external plugins (plugin: [...]) don't execute their module code in MiMoCode 0.38.9.
Cipher208
force-pushed
the
fix/plugin-bugfix-clean
branch
from
July 27, 2026 14:17
6795738 to
a5266ce
Compare
added 4 commits
July 27, 2026 16:49
…wallow The Effect.catch handler at line 392 was silently swallowing errors with Effect.void and no logging. This made it impossible to debug plugin loading failures that occurred in the Effect pipeline itself (after the tryPromise catch handler). Fix: add log.error() call with error details before returning Effect.void. This ensures all plugin loading failures are visible in logs, not just those caught by the tryPromise handler.
Skylos flagged 5 dead-code items in MCP index.ts. After thorough verification across the entire codebase: - Failed (NamedError): truly dead code — not imported or used anywhere outside index.ts. Removed. - NamedError import: only used by Failed. Removed. - defaultLayer: NOT dead code — used in session/prompt.ts, effect/app-runtime.ts, command/index.ts (skylos false positive) - Resource: NOT dead code — used in server/routes/instance/experimental.ts - ToolsChanged: NOT dead code — used at line 498 in same file 4 of 5 skylos findings were false positives.
This reverts commit 26e8036.
Verifies that plugins with non-function exports (constants, types) load correctly after the getLegacyPlugins fix (throw → continue). Before fix: getLegacyPlugins threw TypeError on non-function exports, silently skipping the entire plugin. After fix: non-function exports are skipped, plugin function loads.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1891
Problem
External plugins (
plugin: [...]) don't execute their module code in MiMoCode. The plugin module IS loaded (ESimport()succeeds), but hooks are never registered.Root Cause
getLegacyPlugins()throwsTypeError("Plugin export is not a function")when it encounters ANY export that is not a function and doesn't have aserverproperty (e.g. constants, config objects, type re-exports).This causes the entire plugin to be silently skipped — the error is caught in
applyPlugin'sEffect.catchhandler, which silently swallows the error and returnsEffect.void. The plugin is never loaded, hooks are never registered.Fix
Two changes in
packages/opencode/src/plugin/index.ts:Bug fix (line 163): Change
throwtocontinueso non-plugin exports are silently skipped, matching the behavior ofgetServerPlugin()which already returnsundefinedfor non-plugin values.Logging fix (line 378): Add
log.error()in theEffect.catchhandler so unhandled errors in the plugin loading pipeline are visible in logs, instead of being silently swallowed.Testing
bun typecheck)bun test test/plugin/)Impact