fix(plugin): write server plugin load errors to stderr#21755
Open
YGoetschel wants to merge 2 commits intoanomalyco:devfrom
Open
fix(plugin): write server plugin load errors to stderr#21755YGoetschel wants to merge 2 commits intoanomalyco:devfrom
YGoetschel wants to merge 2 commits intoanomalyco:devfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #21638
Type of change
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:log.error()writes to the log file, which most users never check during development.publishPluginError()fires aSession.Event.Errorbus 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.erroralongsidelog.errorso errors appear in the terminal immediately. This PR applies the same pattern to the server plugin loader: addprocess.stderr.writefor install, entry resolution, and load failures. The existinglog.errorandpublishPluginErrorcalls 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