Repository navigation
Description
Summary
We isolated a reproducible difference between Bun 1.4.0 and Bun 1.4.1 when compiling OpenCode 1.18.31 for an Android/Bionic/Termux environment.
The same OpenCode source and dependency tree behaves correctly when run directly under both Bun 1.4.0 and Bun 1.4.1. The failure appears only in the Bun 1.4.1 compiled/embedded executable path when splitting:true is enabled.
Observed matrix
- OpenCode 1.18.31 source run directly under Bun 1.4.0: PASS (
/api/referenceand/api/agentHTTP 200) - Same source run directly under Bun 1.4.1: PASS
- Bun 1.4.0 compiled Android/Bionic candidate: PASS
- Bun 1.4.1 compiled with
minify:true, splitting:true: FAIL (/api/referenceand/api/agentHTTP 500) - Bun 1.4.1 compiled with
minify:false, splitting:true: FAIL - Bun 1.4.1 compiled with
minify:true, splitting:false: PASS (/api/config,/api/reference,/api/agentHTTP 200) - Fresh Bun 1.4.1 control with normal
splitting:truereproduced the failure
The failing executable reaches an OpenCode internal exception of the form:
TypeError: undefined is not an object (evaluating 'a.name')
Earlier investigation initially suggested a malformed OpenCode reference object, but the A/B controls above challenged that diagnosis: direct source execution passes under Bun 1.4.1, and disabling compile-time splitting makes the compiled 1.4.1 artifact pass without any OpenCode source patch.
Environment
- Android / Termux
- Bionic libc environment
- OpenCode 1.18.31
- Bun 1.4.0 and 1.4.1 compared against the same reconstructed source/dependency tree
@androidtui/core0.5.5
Known-good workaround
Compile OpenCode 1.18.31 with Bun 1.4.1 and:
minify:true, splitting:false
Qualified no-split artifact:
- SHA256:
02367cb9fa073ab37acadd6d4ca35db590f7fd4c775147541104ec604fee6e4e - Size: 188,614,920 bytes
Bun 1.4.0 compiled control artifact:
- SHA256:
26c7610ef19d4982dbd72ed3db7663813543bfcaf4d99834665df1f365bb9905
Interpretation
Current evidence suggests a Bun 1.4.1 compile-time splitting regression on this Android/Bionic path, rather than an ordinary OpenCode source-level defect or minification issue.
We have not yet reduced this to a tiny standalone Bun reproducer outside the OpenCode build tree, so this report is intentionally scoped as a possible Bun regression rather than a universal claim.
If useful, I can provide the exact OpenCode build settings/source locations used to produce the A/B candidates.
Activity
robobun commentedon Sep 16, 2026
I tried to reproduce this with the stock OpenCode 1.18.31 source and Bun 1.4.1 on Linux x64. I do not have an Android device, so I could not run a
bun-linux-aarch64-androidexecutable.Bun version:
1.4.1(release build from GitHub) onlinux x64Attempt 1: Build OpenCode 1.18.31 with its own build script. The script uses
minify: true, splitting: trueandcompile(seepackages/opencode/script/build.ts). Then start the compiled executable and call the agent and config routes.Expected HTTP 500 with
TypeError: undefined is not an object (evaluating 'a.name'). Got HTTP 200 on all routes.Attempt 2: Search the OpenCode 1.18.31 source for the routes in the report.
The stock source has no
/api/referenceor/api/agentroute. The tree that fails is a modified one (@androidtui/coreis a fork of@opentui/core).Conclusion: The stock OpenCode 1.18.31 build with Bun 1.4.1,
splitting: trueandcompileworks on Linux x64. I cannot tell from the report alone whether the failure comes from the Android runtime, from the modified source tree, or from a bundler change between 1.4.0 and 1.4.1.To make progress, please provide:
Bun.buildoptions and the changes to the source tree (the/api/*routes, the@androidtui/coreswap, thetargetvalue).TypeError. Build withminify: falseandsourcemap: "linked"(or"inline") so the trace has file names and the real variable name, nota.--target=bun-linux-x64(or your host target) on a Linux machine. If it fails there too, the Android runtime is not the cause.a.name, its importers, and whether that module is reached throughimport()would already narrow this a lot. Several import() and require() interop changes landed in 1.4.1 (for example bundler: tree-shake unobserved exports of import() / require() targets #32557, bundler: give a split import() of a lifted CommonJS module its namespace as default #41231, bundler: wrap a split import() with __toESM when the target is CommonJS at link time #41237, bundler: read .default of a split require() whose target is CommonJS at link time #41243), so a reduced case around the failing dynamic import is the most useful thing.fix(build): disable bun splitting; pin bun-termux 1.4.2-patched; open…
martinstiago commentedon Sep 18, 2026
Confirming this reproduces on stock opencode on macOS (darwin-arm64) — it's not Android/Bionic- or fork-specific.
(Context: this also blocks anomalyco/opencode#44946, which bumps opencode's embedded Bun to 1.4.x — see the "Blocker" note there. Posting here since the root cause lives in Bun's bundler.)
Setup: unmodified
anomalyco/opencodedev(Sep 18,b02acc1), only change ispackageManager: [email protected]. Built with its own build script (packages/opencode/script/build.ts:Bun.build+compile,minify: true, splitting: true).Matrix:
splitting: truesplitting: truesplitting: falseCrash (with
--sourcemapslinked, hence real file names):A node in the Effect layer graph is
undefined— consistent with cross-chunkmodule-init ordering under ESM splitting in the compiled bundle. Not reproducible from
source on the same Bun versions.
One important note on reproduction: the crash only fires on an actual agent turn
(prompt → system-prompt build → layer resolution). Route-level smoke tests
(
/health,/config,/agent) all return 200 on a broken binary — that may explain whythe stock-source repro attempt above came back clean.
Happy to help narrow further — the
hoist/walkcode inlayer-node.tsaround thoselines is the failing site, and I can test candidate fixes or a minimized repro on darwin-arm64.
fix: pin bun 1.4.0, not 1.4.2, and carry the SSE cancel-rejection bac…
docs: sharpen the bun-pin and tripwire comments after review
[NO-JIRA] Build releases with bun 1.4.0 to stop the 1.5 GB/day /tmp l…
Jarred-Sumner commentedon Sep 26, 2026
Fixed in #42695
robobun commentedon Sep 26, 2026
This is the same bug as #42632: with
splitting: true, a chunk shared by several entry points could print an import cycle in the wrong order, so a hoistedvarwas read asundefined(node.nameinlayer-node.ts).#42695 fixes it and is merged into main (97246d0). I verified on main:
test/bundler/bundler_splitting.test.tspasses, including the tests for this cycle. The fix is not in a tagged release yet (latest tag is 1.4.2). It is in canary (bun upgrade --canary) and ships in the next release.