anomalyco / anomalyco/opencode
Circular import between core/src/filesystem.ts and core/src/filesystem/search.ts leaves an undefined layer dependency
@kitlangton is already working on this.
Since Sep 14, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Every prompt fails with "Failed to send prompt / Unexpected server error". The server log shows:
level=ERROR message=failed ref=err_... error="TypeError: undefined is not an object (evaluating 'a.name')"
It fires on the send-prompt path, right after loop ... step=0.
Cause: filesystem.ts and filesystem/search.ts import each other. filesystem.ts:117 reads the other module eagerly, at module scope:
deps: [FSUtil.node, Location.node, FileSystemSearch.node]
search.ts only reads back lazily, inside Layer.effect bodies, plus three type-only uses. So there is exactly one valid evaluation order, and the build is relying on getting it. Bun 1.4.2's bundler emits the two module bodies the other way round, so FileSystemSearch.node is undefined when that array is built, and the layer graph carries an undefined dependency until something walks it.
I have filed the ordering behaviour against Bun separately (oven-sh/bun#42664). This issue is the circular import itself, which makes opencode sensitive to it in the first place.
OpenCode version
1.18.30
Steps to reproduce
- Install opencode 1.18.30 built with Bun 1.4.2 (e.g.
brew install opencode, revision 1) - Open any session and send a prompt
- Fails immediately;
~/.local/share/opencode/log/opencode.logshows the TypeError above
Operating System
macOS 27.0
Terminal
iTerm2 3.7.1
AI disclosure: investigated with Claude Code (model claude-opus-5); findings verified by me.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.