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 — Plugin loader throws TypeError or executes arbitrary named utility exports in legacy plugins · Issue #50021 · anomalyco/opencode

Plugin loader throws TypeError or executes arbitrary named utility exports in legacy plugins #50021

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Plugin loader throws TypeError or executes arbitrary named utility exports in legacy plugins#50021
Copy link

Description

@rapha4lx
rapha4lx
opened on Sep 19, 2026
Issue body actions

Description

In packages/opencode/src/plugin/index.ts, getLegacyPlugins iterates over all exported values of a plugin module (Object.values(mod)):

for (const entry of Object.values(mod)) {
  if (seen.has(entry)) continue
  seen.add(entry)
  const plugin = getServerPlugin(entry)
  if (!plugin) throw new TypeError("Plugin export is not a function")
  result.push(plugin)
}

This causes two issues when authoring plugins:

  1. 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.
  2. 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

  1. Create a plugin file exporting both a default plugin function and a constant:
export const MY_CONFIG = { foo: "bar" }
export default async function(ctx) {
  return {}
}
  1. Run opencode.
  2. Loading fails with TypeError: Plugin export is not a function.

Operating System

Linux

Activity

  1. thdxr commented on Oct 11, 2026

    @thdxr
    thdxr
    on Oct 11, 2026
    Member
    More actions

    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 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

  2. thdxr
    closed this as not plannedon Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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

      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.