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 — fix(core): keep plugin swaps going when a cleanup fails by neriousy · Pull Request #63548 · anomalyco/opencode

Conversation

@neriousy

@neriousy neriousy commented Nov 12, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Issue for this PR

Closes #49982

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When a plugin is removed or replaced, Plugin.activate closes the old slots in reverse order before loading the new ones. A finalizer that dies aborted that loop. By then the config agent and command plugins, which are last in activation order, were already closed, and the new generation never loaded. Custom agents and commands disappeared until the next reload or a restart, sessions failed with AgentNotFoundError, and plugin.list still reported everything as active. The only trace was failed to reload plugins.

The finalizer that died in the reports is the promise adapter's: it called whatever setup() returned as a cleanup as long as it was truthy, so a plugin returning an object (a v1-style hooks object) threw TypeError: o is not a function on every unload.

Two changes:

  • Plugin.activate closes each old slot on its own and logs failed to clean up plugin with the plugin id when a finalizer fails, so the swap finishes and the later plugins are registered again.
  • The promise adapter only calls a cleanup that is a function.

How did you verify your code works?

  • Reproduced locally with a plugin whose cleanup dies followed by a later builtin that registers a command: before the fix, removing the plugin left the command list empty; after it, the command is registered again and the inventory is correct.
  • test/plugin.test.ts and test/plugin/: 621 pass.

Screenshots / recordings

N/A, not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Fixes #57089

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Filip Hejmowski added 2 commits November 12, 2026 15:49
Filip Hejmowski
fix(core): keep plugin swaps going when a cleanup fails
59e1525
Filip Hejmowski
test(core): drop plugin cleanup regression tests
e776b59
opencodejr[bot]
opencodejr Bot reviewed Nov 12, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reproduced the bug on the base and it's gone with this PR. I ran the #49982 repro script against opencode serve from source in both checkouts. On the base, removing a plugin whose setup returns {} logged failed to reload plugins … cleanup is not a function and dropped the custom review agent and the gcmd/p1–p3 commands in both locations. With this PR they all stay and nothing is logged. The two new tests fail on the base and pass here; test/plugin.test.ts plus test/plugin/ give 621 passing. I couldn't run the typecheck scripts here because they call bun check.

The per-slot catchCause matches how disabled plugins are already cleaned up, and the typeof check in the adapter is the right boundary fix. No concerns.

Public API is unchanged.

Fixes #57089

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
opencodejr[bot]
opencodejr Bot reviewed Nov 12, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit only removes the two regression tests. Since the source changes are the same as at 59e1525e, my earlier verification still applies. With the #49982 repro script from source, the base dropped the custom agents and commands, and this PR keeps them. The plugin tests pass at the new head (627 passing).

The public API is unchanged. No concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@neriousy
neriousy merged commit ec263d6 into dev Nov 12, 2026
14 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@neriousy
neriousy deleted the plugin-teardown-isolation branch November 12, 2026 15:15
@kelos-bot kelos-bot Bot mentioned this pull request Nov 13, 2026
[kanon-fake-strategist] Render hooks per agent capability and add OpenCode hook support kelos-dev/kanon#100
Open
This was referenced Nov 13, 2026
server: failed plugin reload on config change silently drops custom agents and commands until restart #49982
Closed
default_agent silently reverts to the built-in 'build' agent on a hot config reload (no restart) #62002
Closed
@holny holny mentioned this pull request Nov 15, 2026
fix(plugin): only call function return values when tearing down a plugin #57775
Closed
3 tasks done
@ccclucky ccclucky mentioned this pull request Nov 18, 2026
fix(core): pin npm cache generations while a plugin instance uses them #62146
Closed
3 of 6 tasks
This was referenced Nov 24, 2026
server: long-running daemon stops activating configured providers after config hot-reload; restart fixes #66199
Closed
Hot plugin reload fails across locations and silently kills the session (Model unavailable / Agent not found, no reply) #66352
Closed
@four1er four1er mentioned this pull request Nov 25, 2026
fix(plugin): keep previous plugin set when hot reload fails, fail loudly with no providers #66369
Open
3 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

A throwing plugin cleanup during reload aborts the generation swap and silently drops builtin registrations server: failed plugin reload on config change silently drops custom agents and commands until restart

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@neriousy
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.