Skip to content

Plugin silently fails to load when it exports a non-function value #31575

Closed as not planned

Description

@ZachRouan

Description

A plugin that exports anything besides the plugin function — a constant, an array — silently fails to load. No error, the hooks just never fire.

It's getLegacyPlugins in packages/opencode/src/plugin/index.ts: it loops over every export and throws on the first non-function one, and that error gets swallowed by the Effect.catch right below it (the one with the // TODO: make proper events for this comment).

Using the export default { id, server } format works around it, since that path skips getLegacyPlugins entirely — but the docs only show the named-export style, so it's easy to hit. A continue instead of the throw would fix it.

Plugins

No response

OpenCode version

1.16.2

Steps to reproduce

  1. Create a plugin that exports a constant next to the function:
export const VERSION = "1.0.0";
export const MyPlugin = async () => ({
  "tool.execute.before": async () => { console.log("hook fired"); },
});
  1. Add it to opencode.json: "plugin": ["file:///path/to/plugin.js"]
  2. Trigger any tool — the hook never fires, and there's no error anywhere.

Screenshot and/or share link

No response

Operating System

Ubuntu 26.04

Terminal

Ptyxis

Activity

  1. github-actions commented on Aug 9, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions