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: session-hook plugin activation triggers failed reload and wipes provider registry · Issue #52618 · anomalyco/opencode

plugin: session-hook plugin activation triggers failed reload and wipes provider registry #52618

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
plugin: session-hook plugin activation triggers failed reload and wipes provider registry#52618
Copy link
Assignees
kitlangton
Labels
pending closetriaging

Description

@gabrielferreira-cit
gabrielferreira-cit
opened on Oct 2, 2026
Issue body actions

Summary

Saving a plugin file that registers a session.hook("http.request", ...) triggers repeated failed to reload plugins: TypeError: re is not a function across locations, and the provider/model registry drops all custom providers (51 models -> 8). Reverting the file to a no-op restores everything. Observed 4/4 correlated cycles, including once on a freshly restarted service.

Environment

  • opencode version: 2.0.21
  • OS: Linux 7.0.0-34-generic (linux x64)
  • Terminal: WarpTerminal, TERM=xterm-256color, COLORTERM=truecolor
  • Shell: /bin/zsh
  • Install/channel: latest
  • Active plugins: opencode-models-discovery@latest, superpowers@git+https://github.com/obra/superpowers.git, local rtk.ts

Reproduction

  1. Add ~/.config/opencode/plugins/strip-store.ts:
    export default {
      id: "strip-store",
      setup: async (ctx) => {
        await ctx.session.hook("http.request", async (event) => {
          if (event.model.providerID !== "my-gateway") return
          const req = event.request
          if (!(req.headers.get("content-type") ?? "").includes("application/json")) return
          const body = JSON.parse(await req.clone().text())
          if (!("store" in body)) return
          delete body.store
          const headers = new Headers(req.headers)
          headers.delete("content-length")
          event.request = new Request(req.url, {
            method: req.method,
            headers,
            body: JSON.stringify(body),
            duplex: "half",
          })
        })
      },
    }
    
  2. Save the file; the server reloads plugins.
  3. List models: custom providers vanish (only built-in opencode/* remain). The log shows per-location failed to reload plugins with cause="Cause([Die(TypeError: re is not a function. (In 're()', 're' is an instance of Object))])", and occasionally Session.AgentNotFoundError for the configured default agent during the churn.
  4. Revert the file to setup: async () => {} -> registry recovers (verified 4 times).

Expected Behavior

The hook registers and unrelated providers/models are unaffected by a plugin reload.

Actual Behavior

Provider/model registry loses all custom providers on every activation; recovery requires reverting the file (plus sometimes a manual discovery refresh, as the discovery inventory can be left wiped at 0 models).

Additional Context

  • The same failed to reload plugins error (different minified name, fe is not a function) was logged on 2026-09-24 with no such file present, so a pre-existing reload bug is likely being triggered rather than caused by this plugin's code. The plugin itself always reports loading plugin with no load error.
  • While providers vanish, the models-discovery inventory stays intact (42 models / 1 provider), pointing the failure at provider/model registry assembly during reload, not at discovery or at the hook's request handling (the hook body was verified working against an isolated probe endpoint).
  • Related: filed alongside this is the missing compatibility.supportsStore config-schema key, which is why the hook workaround was needed at all.

Activity

  1. github-actions
    assigned
    kitlangton
    on Oct 2, 2026
  2. github-actions commented on Oct 2, 2026

    @github-actions
    github-actionsBot
    on Oct 2, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue might be a duplicate of existing issues. Please check:

    • server: failed plugin reload on config change silently drops custom agents and commands until restart #49982: Failed plugin reloads silently drop custom agents and commands until the service restarts, with a similar TypeError: ... is not a function failure.
    • core: concurrent location plugin reloads crash with r.base.get #48121: Concurrent per-location plugin reloads crash with Effect context lookup errors and can make providers or agents unavailable.
  3. nkoynov commented on Oct 7, 2026

    @nkoynov
    nkoynov
    on Oct 7, 2026
    More actions

    Another trigger and the blast radius on 2.0.24: saving a local plugin file (content-digested) reloads that plugin and every plugin after it in boot order, and the built-in post plugins always come after local ones (ConfigProviderPlugin, ConfigAgentPlugin, ConfigSkillPlugin, ConfigPolicyPlugin, …), in every booted Location. Measured: config agents gone for ~90 ms, half the skills for ~150 ms, a custom provider briefly missing from GET /api/provider. A turn running during reloads also gets skill-removed/added and full Code Mode catalog notices, up to ~20 KB per reload.

  4. opencodejr commented on Oct 28, 2026

    @opencodejr
    opencodejrBot
    on Oct 28, 2026
    Contributor
    More actions

    Thanks for the detailed report and the correlation testing. I think this is a duplicate of #49982. There, a plugin reload on the background service fails with the same failed to reload plugins … TypeError: <x> is not a function. (In '<x>()', '<x>' is an instance of Object). After that, everything the plugin generation had registered disappears from every location until the reload succeeds or the service restarts. In that report it was custom agents and commands; for you it shows up as the custom providers and models going missing. Your note that the same error appeared earlier without this file fits: your hook plugin looks like the trigger, not the cause.

    Possible duplicates and closely related issues, ordered from most to least likely:

    • server: failed plugin reload on config change silently drops custom agents and commands until restart #49982: failed plugin reload with the same … is not a function … instance of Object error silently drops registrations across all locations
    • Hot plugin reload destroys the shared agent/skill registry for all locations (TypeError: o is not a function) #59443: hot plugin reload throws o is not a function and wipes the shared registry for every location, with AgentNotFoundError; already marked a duplicate of server: failed plugin reload on config change silently drops custom agents and commands until restart #49982
    • fix(plugin): only call function return values when tearing down a plugin #57775: open PR that only treats a plugin's setup() return value as a cleanup callback if it is actually a function; this matches the instance of Object error, so another loaded plugin returning an object from setup() may be the real trigger
    • A throwing plugin cleanup during reload aborts the generation swap and silently drops builtin registrations #57089: a reload that fails during teardown aborts the generation swap and drops builtin registrations
    • config: compatibility.supportsStore silently dropped from opencode.jsonc #52617: your companion report about compatibility.supportsStore being dropped from config

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.

  5. opencodejr
    added
    pending close
    triaging
    on Oct 28, 2026
  6. opencodejr
    closed this as duplicateon Oct 29, 2026
  7. opencodejr commented on Oct 29, 2026

    @opencodejr
    opencodejrBot
    on Oct 29, 2026
    Contributor
    More actions

    Closing this as a duplicate of #49982, since there's been no reply in the past day saying how this differs. Both reports describe the same problem: a plugin reload fails with TypeError: <x> is not a function. (In '<x>()', '<x>' is an instance of Object), and afterwards everything the plugins had registered is missing in every location. For you that meant the custom providers and models; in #49982 it was custom agents and commands. Please follow #49982 for updates. The open PR #57775 addresses the instance of Object error, and #57089 covers a related reload failure. If you can show that this behaves differently, for example the providers disappearing without a failed to reload plugins error, please comment here and we'll take another look.

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

Metadata

Metadata

Assignees

  • @kitlangton
    kitlangton

Labels

pending closetriaging

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.