Skip to content

fix(cli): disable Bun code-splitting to fix baseline release crash - #10958

Merged
catrielmuller merged 2 commits into
mainfrom
fix/cli-disable-bun-splitting
Jun 5, 2026
Merged

fix(cli): disable Bun code-splitting to fix baseline release crash#10958
catrielmuller merged 2 commits into
mainfrom
fix/cli-disable-bun-splitting

Conversation

@catrielmuller

Copy link
Copy Markdown
Contributor

Issue

Follow-up to #10955, #10956, #10957. Despite the morphsdk CJS redirect, the build-cli job still fails — now at the cli-linux-x64-baseline smoke test:

Smoke test failed for @kilocode/cli-linux-x64-baseline:
  SyntaxError: Exported binding 'G9' needs to refer to a top-level declared variable.
  Bun v1.3.14 (Linux x64 baseline)

See https://github.com/Kilo-Org/kilocode/actions/runs/27035450876/job/79798417163.

Root cause — it was never morphsdk

The previous fixes targeted @morphllm/morphsdk on the theory that its pre-split ESM barrel was feeding bad chunks to Bun's splitter. Inspecting the compiled binary disproves that:

  • The morphsdk redirect worksclient.cjs content is embedded, no morphsdk chunk-*.js imports remain.
  • The SyntaxError is a runtime crash at binary startup, not a build-time error.
  • The offending code is import{vn as G9}from"/$bunfs/root/chunk-*.js" — a cross-chunk re-export Bun itself generates under splitting: true, where the exported binding isn't top-level.

This is a known Bun 1.3.14 code-splitting bug (oven-sh/bun#25621, #5344, #7265; also hit by opencode#23349), fixed upstream in Bun#26089 (post-1.3.14). It only crashes on the baseline target, whose stricter runtime rejects the invalid binding.

Fix

Set splitting: false in script/build.ts. Splitting only deduplicated shared code between the 5 entrypoints (index + 4 workers); disabling it inlines per entrypoint and produces a valid binary. The morphsdk redirect is kept (harmless, simplifies the bundle) but its comments are corrected to note it is not the actual fix.

Verification

Built locally from packages/opencode/ with the real script/build.ts and inspected the compiled binary:

splitting build as G9 in binary
true (before) ok present → baseline crashes
false (after) ok gone
  • bun run typecheck passes.
  • bun run script/check-opencode-annotations.ts passes.

The local smoke test exits 139 on my Nix host — a pre-existing environment segfault in Bun's compiled-binary bootstrap (crashes right after execve, before any JS), unrelated to this change and not present on CI's Ubuntu runners.

No changeset — CI-only build fix.

The real cause of the 'Exported binding G9 needs to refer to a top-level
declared variable' SyntaxError is a Bun 1.3.14 --splitting codegen bug
(oven-sh/bun#25621), not @morphllm/morphsdk. With splitting:true Bun emits
invalid cross-chunk re-exports (import{vn as G9}) that crash the compiled
baseline binary at startup. Disabling splitting produces a valid binary;
verified the 'as G9' artifact is gone from the compiled output.
The compat re-export and the build's CJS-redirect plugin only existed to work
around the 'G9' crash that's actually a Bun --splitting bug (now fixed by
splitting:false). With splitting off the morphsdk ESM barrel bundles cleanly,
so import it directly in warpgrep.ts and remove the indirection.
@kilo-code-bot

kilo-code-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • packages/opencode/script/build.ts — removed morphsdkCjsPlugin, added splitting: false with explanation comment
  • packages/opencode/src/kilocode/compat/morphsdk.ts — deleted (compat shim no longer needed)
  • packages/opencode/src/tool/warpgrep.ts — reverted to direct import from @morphllm/morphsdk/tools/warp-grep/client

lgtm — the root cause analysis is sound, the fix is minimal and correct. splitting: false directly addresses the Bun 1.3.14 codegen bug without introducing side effects. The compat shim and its plugin were the wrong workaround and are cleanly removed. kilocode_change markers are properly placed.


Reviewed by claude-4.6-sonnet-20260217 · 294,858 tokens

Review guidance: REVIEW.md from base branch main

@catrielmuller
catrielmuller merged commit 9a53a60 into main Jun 5, 2026
22 of 24 checks passed
@catrielmuller
catrielmuller deleted the fix/cli-disable-bun-splitting branch June 5, 2026 20:46
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…plitting

fix(cli): disable Bun code-splitting to fix baseline release crash
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.

2 participants