You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Plugin loader throws TypeError or executes arbitrary named utility exports in legacy plugins #50021
In packages/opencode/src/plugin/index.ts, getLegacyPlugins iterates over all exported values of a plugin module (Object.values(mod)):
for(constentryofObject.values(mod)){if(seen.has(entry))continueseen.add(entry)constplugin=getServerPlugin(entry)if(!plugin)thrownewTypeError("Plugin export is not a function")result.push(plugin)}
This causes two issues when authoring plugins:
If a plugin file contains export default async function(ctx) { ... } alongside non-function exports (e.g. export const config = { ... } or constants), getServerPlugin returns undefined for non-functions and it throws TypeError: Plugin export is not a function, failing plugin load.
If a plugin exports helper functions (e.g. for unit testing), OpenCode treats every exported function as a plugin initializer and invokes it with (input, load.options), causing unexpected calls or exceptions when the helper expects different arguments.
OpenCode version
1.18.31
Steps to reproduce
Create a plugin file exporting both a default plugin function and a constant:
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.
Activity
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊