Conversation
….30 loader crashes on it
opencode's plugin loader treats any export whose value is a function as a
plugin factory and crashes the server at startup ('plugin config hook failed
(N.config)'). The plugin's named export runWithSpuriousRetry (added for the
retry unit guard) therefore broke opencode launch entirely: 'Unexpected server
error' before the first prompt.
Expose it as a property on a const object instead ('retry.runWithSpuriousRetry')
and point retry_test.ts at that. Reproduced standalone: opencode run fails to
boot with the function-valued export present, boots cleanly (\pong\) without
it; the retry guard still passes (ALL OK).
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.
Problem
opencode (>= the 1.18 line, tested on
opencode-ai@1.18.30) fails to start when the code-preview plugin is installed:opencode rundies withUnexpected server error. Check server logs for details.and the server logs show:plugin config hook failed—undefined is not an object (evaluating 'N.config')Event listener failed—undefined is not an object (evaluating 'V.event')Root cause is the plugin module's named function export
runWithSpuriousRetry. opencode's plugin loader treats any export whose value is a function as a plugin factory. When it can't process it (it has noconfig/eventshape), it throws during startup — before the first prompt. Every other export form is fine (default export, named const with a scalar, named const whose value is an object).Reproduced standalone with minimal plugins against
opencode 1.18.30:opencode run pingexport async function f() {}(+/- default)export const f = async () => {}pongexport const retry = { run: ... }+ defaultpongFix
backends/opencode/index.ts— drop theexportkeyword fromrunWithSpuriousRetryand expose it as a property on a const object:export const retry = { runWithSpuriousRetry }. The plugin module now only has a default export (its hooks) plus the const, so the server boots.tests/backends/opencode/retry_test.ts— read the helper frommod.retry.runWithSpuriousRetryinstead ofmod.runWithSpuriousRetry.Behavior is unchanged: the hooks still call the same retry helper, and the unit guard still exercises it.
Verification
opencode run ping→pong(exit 0). Before the fix, the same setup →Unexpected server error(exit 1). Tested on Windows, opencode 1.18.30.tsx tests/backends/opencode/retry_test.ts→ all 5 checks pass,ALL OK.