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): prevent duplicate plugin function initialization by ShpetimA · Pull Request #6787 · anomalyco/opencode

Conversation

@ShpetimA

@ShpetimA ShpetimA commented Jan 4, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Fixes #6596 If in plugin file you have two exports:
export const YourPlugin: Plugin = async () => { ... }
export default YourPlugin

// When imported:
const mod = await import(plugin)
Object.entries(mod)
// Returns: [["YourPlugin", fn], ["default", fn]]
// Both point to the SAME function reference

So the plugin function fn gets called twice in the loop, creating two separate hook instances. The seen Set now catches this by checking if we've already processed that exact function reference.

Im building an opencode plugin and noticed the issue, in the video you can see i run bun run dev with the fix and when running oc alias for opencode it calls plugin twice.

Screen.Recording.2026-01-04.at.12.47.50.AM.mov

Sorry, something went wrong.

Uh oh!

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

All reactions
Shpetim
fix(plugin): prevent duplicate plugin function initialization
bdefdee
@EvanZhouDev

EvanZhouDev commented Jan 4, 2026

Copy link
Copy Markdown

Perhaps there isn't anyone doing this, but in either case this is not backwards compatible.

People could have potentially relied on plugins registering twice for unique behavior, and this could break things. Not too sure if this is acceptable or we can put a config on it

All reactions

Sorry, something went wrong.

Uh oh!

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

@ShpetimA

ShpetimA commented Jan 4, 2026

Copy link
Copy Markdown
Contributor Author

@EvanZhouDev I don't see a case where it would make sense to register the same plugin twice but yes if this is a thing that could break other plugins then we could add a failsafe. But @rekram1-node could give better input here

All reactions

Sorry, something went wrong.

Uh oh!

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

@rekram1-node

rekram1-node commented Jan 4, 2026

Copy link
Copy Markdown
Member

hm i doubt anyone is using that behavior lemme look at this pr and we should look at the top plugins like memory one, omo, and antigravity

All reactions

Sorry, something went wrong.

Uh oh!

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

@rekram1-node

rekram1-node commented Jan 4, 2026

Copy link
Copy Markdown
Member

We should write a comment about it like for why it is there

All reactions

Sorry, something went wrong.

Uh oh!

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

@rekram1-node

rekram1-node commented Jan 4, 2026

Copy link
Copy Markdown
Member

/review

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions

github-actions Bot commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

lgtm

All reactions

Sorry, something went wrong.

Uh oh!

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

@rekram1-node

rekram1-node commented Jan 4, 2026

Copy link
Copy Markdown
Member

/oc add a comment to this change explaining why

All reactions

Sorry, something went wrong.

Uh oh!

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

@opencode-agent @rekram1-node
Add comment explaining seen Set usage
36fb805
Co-authored-by: rekram1-node <[email protected]>
@opencode-agent

opencode-agent Bot commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

Added a comment explaining why the seen Set is needed. The comment clarifies that when a plugin exports the same function as both a named export and a default export, Object.entries() returns both entries pointing to the same function reference, which would cause the plugin to be initialized twice without this deduplication check.

New%20session%20-%202026-01-04T07%3A17%3A15.476Z
opencode session  |  github run

All reactions

Sorry, something went wrong.

Uh oh!

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

@rekram1-node
rekram1-node merged commit c3fd3c8 into anomalyco:dev Jan 4, 2026
@ShpetimA
ShpetimA deleted the fix-plugin branch January 10, 2026 16:33
@LIHUA919 LIHUA919 mentioned this pull request Jan 18, 2026
Memory leak #9151
Closed
triklozoid pushed a commit to triklozoid/opencode that referenced this pull request Feb 2, 2026
@ShpetimA Shpetim
@opencode-agent @rekram1-node @triklozoid
fix(plugin): prevent duplicate plugin function initialization (anomal…
46cfed3
…yco#6787)

Co-authored-by: Shpetim <[email protected]>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: rekram1-node <[email protected]>
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request May 5, 2026
@ShpetimA Shpetim
@opencode-agent @rekram1-node
fix(plugin): prevent duplicate plugin function initialization (anomal…
9e8baa3
…yco#6787)

Co-authored-by: Shpetim <[email protected]>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: rekram1-node <[email protected]>
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
@ShpetimA Shpetim
@opencode-agent @rekram1-node
fix(plugin): prevent duplicate plugin function initialization (anomal…
cded2bb
…yco#6787)

Co-authored-by: Shpetim <[email protected]>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: rekram1-node <[email protected]>
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request Jun 14, 2026
@ShpetimA Shpetim
@opencode-agent @rekram1-node
fix(plugin): prevent duplicate plugin function initialization (anomal…
d0465c6
…yco#6787)

Co-authored-by: Shpetim <[email protected]>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: rekram1-node <[email protected]>
MarsQiu007 referenced this pull request in MarsQiu007/openNovel Jul 31, 2026
@ShpetimA Shpetim
@opencode-agent @rekram1-node
fix(plugin): prevent duplicate plugin function initialization (#6787)
8a0337d
Co-authored-by: Shpetim <[email protected]>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: rekram1-node <[email protected]>
meSingh pushed a commit to meSingh/opencode that referenced this pull request Sep 6, 2026
@ShpetimA Shpetim
@opencode-agent @rekram1-node
fix(plugin): prevent duplicate plugin function initialization (anomal…
d951b96
…yco#6787)

Co-authored-by: Shpetim <[email protected]>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: rekram1-node <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

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.

[BUG]: Plugin Registering Twice

Uh oh!

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

3 participants

@ShpetimA @EvanZhouDev @rekram1-node
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.