fix: await async generator return value in warpgrep_codebase_search (Bun compatibility Issue)#25
Merged
bhaktatejas922 merged 1 commit intoJun 17, 2026
Conversation
The morphsdk WarpGrepClient.execute() async generator returns a Promise from processAgentResult() via `return promise`. Node.js auto-awaits it per ECMAScript spec, but Bun does not — the unresolved Promise becomes the .next() value. Without the explicit await, result was a Promise whose .success was undefined, and formatWarpGrepResult returned the generic failure message: "Search failed: search returned no error details." The fix is a single line: `result = await value`. This is harmless on Node.js (await on a non-Promise is a no-op) and resolves the Promise on Bun. Closes morphllm#24
c2e7c53 to
9a8d60a
Compare
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.
Summary
warpgrep_codebase_searchconsistently returned no contexts when the plugin runs inside OpenCode (Bun runtime):Root cause
The morphsdk
WarpGrepClient.execute()withstreamSteps: trueis an async generator. Its finalreturn processAgentResult(...)hands back a Promise. Per ECMAScript spec, async generators should auto-awaitreturnvalues, and Node.js does. Bun does not — it yields the unresolved Promise as the.next()value.The plugin consumed the generator with:
So
resultwas a Promise whose.successwasundefined, andformatWarpGrepResultreturned the generic failure message.Fix
One line:
This is harmless on Node.js (await on a non-Promise is a no-op) and fixes Bun.
Fixes #24.
Changes
awaitthe async generator return value inwarpgrep_codebase_search.execute().Diagnosis trail
Initial hypothesis (worktree pointing at OpenCode snapshot git dir) was ruled out by diagnostic logging:
directoryandworktreeboth correctly pointed at the real workspace (isWorktreeGitMetadata=false). The actual issue was found by dumping theresultobject, which had all fieldsundefined— confirming an unresolved Promise was being used as the result.Direct SDK calls via
nodesucceeded because Node.js auto-awaits async generator return values per spec. The failure only occurred through the plugin running inside OpenCode (Bun runtime).Reproduction
Result before fix:
After fix: returns contexts for
README.mdandCHANGELOG.md.Validation
Baseline before changes was
66 pass / 0 fail; the one new test brings it to67 pass / 0 fail.Verified end-to-end in OpenCode (Bun runtime):
warpgrep_codebase_searchnow returns contexts successfully.Environment
@morphllm/opencode-morph-plugin: 2.0.13@morphllm/morphsdk: 0.2.173Notes
This is a plugin-side workaround for a Bun runtime quirk. The underlying issue is in morphsdk'"'"'s async generator (
return processAgentResult(...)withoutawait), but since morphsdk is a separate package and the one-lineawaitworks across both Node.js and Bun, the plugin-side fix is the safest minimal change.