Skip to content

fix(core): break circular import between filesystem and filesystem/search - #49118

Closed
winter765 wants to merge 1 commit into
anomalyco:devfrom
winter765:fix/filesystem-circular-import
Closed

winter765 wants to merge 1 commit into
anomalyco:devfrom
winter765:fix/filesystem-circular-import

Conversation

@winter765

Copy link
Copy Markdown

filesystem.ts reads FileSystemSearch.node while it initializes, while filesystem/search.ts imported FileSystem back from ../filesystem at runtime for the Entry/Match constructors.

A bundler is free to emit either module first. When filesystem.ts wins, FileSystemSearch.node is still undefined and is stored in its layer dependencies, so LayerNode.hoist throws TypeError: undefined is not an object (evaluating 'a.name') on every startup.

Repro: bun run script/build.ts --single on bun 1.4.2 produces a binary that fails at init for every prompt. bun 1.3.14 happens to emit the modules in the other order, which is why this is currently latent.

Entry/Match are re-exports of @opencode-ai/schema/filesystem, so importing them from there removes the runtime edge. The remaining ../filesystem import is type-only.

…arch

`filesystem.ts` reads `FileSystemSearch.node` while the module initializes, but
`filesystem/search.ts` imported `FileSystem` back from `../filesystem` at
runtime for the `Entry`/`Match` constructors. Bundlers may emit either module
first; when `filesystem.ts` wins, `FileSystemSearch.node` is still undefined and
is baked into its layer dependencies, so `LayerNode.hoist` throws
`TypeError: undefined is not an object (evaluating 'a.name')` on every boot.

`Entry` and `Match` come from `@opencode-ai/schema/filesystem`, which
`filesystem.ts` merely re-exports, so importing them from there removes the
runtime edge. The remaining `../filesystem` import is type-only.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, I found a potential duplicate:

This PR appears to address the exact same issue: breaking the circular import cycle between filesystem.ts and filesystem/search.ts. Since PR #49118 (the current PR) has nearly identical scope and title, you should check if #48877 is still open and whether it has already been merged or closed. If it's open, one of these PRs may be redundant.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 15, 2026
@github-actions github-actions Bot closed this Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant