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(plugin): only call function return values when tearing down a plugin by holny · Pull Request #57775 · anomalyco/opencode

Conversation

@holny

@holny holny commented Oct 21, 2026 •
edited by opencode-agent Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #57719

Type of change

  • Bug fix

What does this PR do?

A plugin's setup() runs as JavaScript, so it may return anything. The teardown that runs when the previous plugin generation is released only checked the returned value for truthiness and then called it:

(cleanup) => (cleanup ? Effect.promise(() => Promise.resolve(cleanup())) : Effect.void)

A plugin whose setup() returns an object therefore hits cleanup() and the reload dies with TypeError: o is not a function, which surfaces as opencode reload failing against the background service.

Only a real function counts as a cleanup callback now, so a plugin that returns something else is simply left without a teardown hook.

This is a different layer from #57096: that PR isolates a cleanup that throws so one plugin cannot abort the whole activation, while this one avoids calling a value that was never a cleanup function in the first place. The two are complementary — a plugin can still return a well-formed cleanup that throws, and #57096 covers that.

How did you verify your code works?

  • New regression test in packages/core/test/plugin/supervisor-reload.test.ts loads a local plugin whose setup() returns an object, then triggers a reload and asserts the new generation replaces the old one instead of the reload dying. Red/green checked: the previous truthiness check fails that case, the fix passes it.
  • bun test test/plugin/supervisor-reload.test.ts is 9/9.
  • bun test test/plugin/ is 396/397, with the single failure being a pre-existing timeout in module.test.ts that reproduces on the base commit.
  • bun typecheck clean in packages/core and packages/plugin.

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).

Related: #57089

Sorry, something went wrong.

Uh oh!

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

All reactions
@holny
fix(plugin): only call function return values when tearing down a plugin
e204fed
A plugin's setup() is JavaScript at runtime, so it may return anything. The
teardown that runs when the previous plugin generation is released checked
the returned value for truthiness and then called it, so a plugin whose
setup() returned an object aborted the whole reload with
"TypeError: cleanup is not a function".

Only a real function counts as a cleanup callback now.

Regression test in test/plugin/supervisor-reload.test.ts drives a reload
against a plugin whose setup() returns an object and asserts the new
generation replaces the old one. Red/green checked: the previous
truthiness check fails that case, the fix passes it.

Verification: `bun test test/plugin/supervisor-reload.test.ts` is 9/9;
`bun test test/plugin/` is 396/397 with the single failure being a
pre-existing timeout in module.test.ts that reproduces on the base
commit; `bun typecheck` clean in packages/core and packages/plugin.
@github-actions github-actions Bot added the contributor label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

All reactions

Sorry, something went wrong.

Uh oh!

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

opencode-agent[bot]
opencode-agent Bot reviewed Oct 21, 2026
View reviewed changes

@opencode-agent opencode-agent 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 fix works. I ran the #57719 reproduction from source on both checkouts. On the base, with a plugin whose setup() returns an object, opencode reload fails with TypeError: cleanup is not a function (adapter.ts:621). With this PR every reload prints Configuration reloaded. The new test in supervisor-reload.test.ts fails on the base and passes here. The rest of that file shows one failure, which also fails on the base. Type checks are clean in packages/plugin and packages/core.

Public API: unchanged. A non-function value returned from setup() is now ignored instead of called as a cleanup function, so existing plugins are unaffected.

No concerns. The fix is in the right place (the adapter, where the cleanup is called) and complements #57096, which handles a cleanup that throws.

Related: #57089

Sorry, something went wrong.

Uh oh!

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

All reactions
@opencode-agent opencode-agent Bot mentioned this pull request Oct 26, 2026
Hot plugin reload destroys the shared agent/skill registry for all locations (TypeError: o is not a function) #59443
Closed
@opencodejr opencodejr Bot mentioned this pull request Oct 28, 2026
plugin: session-hook plugin activation triggers failed reload and wipes provider registry #52618
Closed
@holny

holny commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Closing for now to free an open-PR slot — the branch stays put and I'll reopen if the teardown guard still needs a home after the current cleanup cycle.

All reactions

Sorry, something went wrong.

Uh oh!

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

@holny holny closed this Nov 7, 2026
@holny holny reopened this Nov 7, 2026
@holny holny mentioned this pull request Nov 10, 2026
server: failed plugin reload on config change silently drops custom agents and commands until restart #49982
Closed
@OAtulA OAtulA mentioned this pull request Nov 13, 2026
plugin: non-Effect "effect" export hangs activation, 503s /api/provider and /api/model #63816
Open
@holny

holny commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing this in favour of the direct fix that landed in dev: #63548 (ec263d6) guards the teardown cleanup with typeof cleanup === "function" on the same acquireRelease line in adapter.ts, and additionally keeps a failing finalizer from aborting the plugin swap in plugin.ts. Same semantics, so keeping a duplicate open isn't useful.

If anyone picking up issue #57719 wants the supervisor-reload regression test from this branch, feel free to lift it.

All reactions

Sorry, something went wrong.

Uh oh!

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

@holny holny closed this Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencode-agent opencode-agent[bot] opencode-agent[bot] left review comments

Uh oh!

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

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

cli: opencode reload against the background service crashes with TypeError in ServerProcess.start / Worktree.refresh (2.1.2, Windows); --standalone reload works

Uh oh!

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

1 participant

@holny
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.