Repository navigation
Closed as duplicate
Closed as duplicate
Copy link
Labels
Description
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, localrtk.ts
Reproduction
- 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", }) }) }, }
- Save the file; the server reloads plugins.
- List models: custom providers vanish (only built-in
opencode/*remain). The log shows per-locationfailed to reload pluginswithcause="Cause([Die(TypeError: re is not a function. (In 're()', 're' is an instance of Object))])", and occasionallySession.AgentNotFoundErrorfor the configured default agent during the churn. - 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 pluginserror (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 reportsloading pluginwith 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.supportsStoreconfig-schema key, which is why the hook workaround was needed at all.
Activity
github-actions commentedon Oct 2, 2026
This issue might be a duplicate of existing issues. Please check:
TypeError: ... is not a functionfailure.nkoynov commentedon Oct 7, 2026
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
postplugins 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 fromGET /api/provider. A turn running during reloads also gets skill-removed/added and full Code Mode catalog notices, up to ~20 KB per reload.opencodejr commentedon Oct 28, 2026
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:
… is not a function … instance of Objecterror silently drops registrations across all locationso is not a functionand wipes the shared registry for every location, withAgentNotFoundError; already marked a duplicate of server: failed plugin reload on config change silently drops custom agents and commands until restart #49982setup()return value as a cleanup callback if it is actually a function; this matches theinstance of Objecterror, so another loaded plugin returning an object fromsetup()may be the real triggercompatibility.supportsStorebeing dropped from configThe bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
opencodejr commentedon Oct 29, 2026
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 theinstance of Objecterror, and #57089 covers a related reload failure. If you can show that this behaves differently, for example the providers disappearing without afailed to reload pluginserror, please comment here and we'll take another look.