fix: resolve circular sibling imports causing runtime ReferenceError#22752
Merged
kitlangton merged 1 commit intodevfrom Apr 16, 2026
Merged
fix: resolve circular sibling imports causing runtime ReferenceError#22752kitlangton merged 1 commit intodevfrom
kitlangton merged 1 commit intodevfrom
Conversation
EffectLogger.logger was accessed at module scope in observability.ts before it finished initializing — caused by importing through the barrel (index.ts) instead of directly from the sibling file. Fixed the same pattern across all directories: sibling files that import through their own barrel now import directly from the source.
jerome-benoit
pushed a commit
to jerome-benoit/opencode
that referenced
this pull request
Apr 16, 2026
xywsxp
pushed a commit
to xywsxp/opencode
that referenced
this pull request
Apr 24, 2026
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
Fix
ReferenceError: Cannot access 'logger' before initializationcaused by circular imports through barrel files.When sibling files in the same directory import through their own
index.tsbarrel (e.g.observability.tsimportingEffectLoggerfrom"."), the module evaluation order can cause values to be accessed before they're initialized.Fix
Changed all sibling-to-sibling imports to go directly to the source file instead of through the barrel:
23 files across effect/, config/, project/, lsp/, session/, share/, util/, provider/.
Root cause
The namespace migration changed
import { X } from "./sibling"toimport { X } from "."for sibling files. This created circular import chains sinceindex.tsre-exports all siblings. Module-scope expressions that accessed the imported values (likeEffectLogger.loggerin aLogger.layer()call) crashed because the dependency hadn't finished evaluating yet.