Skip to content

core: plugin event subscriptions receive events from every location #57474

Closed as not planned

Description

@WilliamAGH

Description

A plugin's ctx.event.subscribe() receives events from every loaded location, not only its own. Events a plugin publishes carry no location, so they reach every client.

Plugin activation rebuilds the fiber context from only a Scope and the loggers (packages/core/src/plugin.ts:70), which drops Location.Service. The bus uses the ambient Location to filter subscriptions (bus.ts:734) and to stamp publishes (bus.ts:515). Internal plugins are not affected.

I hit this with a plugin that calls ctx.command.reload() on skill.updated. Every copy of it, one per loaded location, reloaded on any location's skill change. A shared opencode serve --service with about 15 TUI clients logged about 135,000 command.updated events in 9 hours.

Possibly related: #36677.

Plugins

A local plugin that reloads commands on skill.updated

OpenCode version

2.0.32, and current dev

Steps to reproduce

  1. Add a plugin that runs ctx.command.reload() whenever ctx.event.subscribe() yields skill.updated.
  2. Open sessions in two directories against one server.
  3. Change a skill in one directory.
  4. The server publishes two command.updated events with no location. Expected: one, for that directory.

Screenshot

No response

Operating System

macOS 27

Terminal

No response

Activity

  1. opencode-agent commented on Oct 20, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed write-up and for tracking down the cause.

    I think this is a duplicate of #56290. That issue reports the same ctx.event.subscribe() problem, and its reproduction found that the multiplier is the number of loaded locations, as you describe. Possible duplicates and related items, most likely first:

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

  2. WilliamAGH commented on Oct 20, 2026

    @WilliamAGH
    Author

    Duplicate of #56290; the fix is tracked in #57186.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions