anomalyco / anomalyco/opencode
Config dependency install can produce orphaned OpenTelemetry spans
@rekram1-node is already working on this.
Since Sep 4, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
When OTel tracing is enabled, child spans from background config dependency installation can be exported without their parent span.
I originally noticed this while inspecting OpenCode traces in Jaeger. In the observed traces, child spans such as FileSystem.existsSafe and EffectFlock.acquire were exported successfully, while their parent spans were missing.
The missing spans came from config dependency work started in src/config/config.ts. The dependency install is launched with Effect.forkDetach, so the fiber can outlive the Config/instance scope that initiated it.
The child spans still had valid parentSpanId values, so this does not appear to be a context propagation issue. Instead, the parent span can remain open in the detached fiber while the surrounding Config/instance lifecycle and telemetry are shutting down.
Plugins
None required to reproduce.
OpenCode version
Reproduced on the current dev branch (8a6cf2c9aa). Originally observed in v1.18.21.
Steps to reproduce
Apply the attached reproducer patch on the current dev branch:
git apply config-fork-lifecycle-repro.patch
bun test test/config/config.test.ts \
-t "exports the parent span for background config dependency install"
The test fails because the child span is exported while its referenced parent span is missing.
Replacing forkDetach with forkScoped in src/config/config.ts makes the same test pass. If this direction sounds reasonable, I’d be happy to open a PR with the forkScoped change.
Screenshot and/or share link
The screenshot below shows a trace with two missing-parent spans. The attached reproducer provides a deterministic test for the same behavior.
Operating System
NixOS 26.11 (Zokor)
Terminal
Wezterm
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.