Skip to content

fix(plugin): write server plugin load errors to stderr#21755

Open
YGoetschel wants to merge 2 commits intoanomalyco:devfrom
YGoetschel:fix/plugin-local-error-visibility
Open

fix(plugin): write server plugin load errors to stderr#21755
YGoetschel wants to merge 2 commits intoanomalyco:devfrom
YGoetschel:fix/plugin-local-error-visibility

Conversation

@YGoetschel
Copy link
Copy Markdown

Issue for this PR

Closes #21638

Type of change

  • Bug fix

What does this PR do?

When a local plugin (e.g. .opencode/plugins/my-plugin.ts) fails to load, the error was silently dropped. Two things work against visibility:

  1. log.error() writes to the log file, which most users never check during development.
  2. publishPluginError() fires a Session.Event.Error bus event — but plugins load at startup before any session is created, so there are no subscribers and the event is dropped.

The TUI plugin runtime already handles this correctly by calling console.error alongside log.error so errors appear in the terminal immediately. This PR applies the same pattern to the server plugin loader: add process.stderr.write for install, entry resolution, and load failures. The existing log.error and publishPluginError calls are kept so in-session errors still appear in the UI.

How did you verify your code works?

Ran bun test test/plugin/loader-shared.test.ts — all 27 tests pass. The stderr output from error paths is visible in the test output, confirming each error case now surfaces correctly.

Screenshots / recordings

No UI screenshot — the fix makes terminal output appear where there was none before.

Checklist

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

YGoetschel and others added 2 commits April 9, 2026 22:12
Plugin load failures were only sent to the log file and the session
event bus. The bus event is published before any session exists at
startup, so it is silently dropped. Log files are not checked by
most users during normal development.

Mirror what the TUI plugin runtime already does: write to process.stderr
so errors are immediately visible in the terminal regardless of session
state. The existing log.error and publishPluginError calls are kept.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loading local plugin silently fails in case of an error

1 participant