fix(cli): preserve server startup failure cause#36478
Open
kitlangton wants to merge 1 commit into
Open
Conversation
fac667c to
18d0d52
Compare
18d0d52 to
9ff7df0
Compare
9ff7df0 to
3b03692
Compare
This was referenced Jul 12, 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.
What
When the managed background service exits before registering, the CLI now explains what happened and what to do next instead of dumping a raw Effect error and bundled stack frames.
1. The background service does not register
OpenCode starts its normal managed-service flow, but the child exits before creating its registration.
2. OpenCode presents the failure
The product output stays concise and uses the shipped CLI name for its recovery commands.
The default terminal no longer exposes
/$bunfs/rootpaths or Effect frames. The complete typed cause remains in OpenCode's normal file log for debug diagnosis.How
packages/client/src/effect/service.tsreturns a typedService.StartErrorwithspawn,registration, orreadinessstage information and preserves the original cause. Spawn completion now observes the child process'sspawn/errorevents, so command launch failures are classified directly.packages/cli/src/framework/startup-error.tshandles onlyService.StartErrorat the CLI's top-level Effect boundary. It writes the user-facing presentation, records the full Effect cause through the existing observability layer, and leaves unrelated failures on the existing renderer.Commands.name, which is injected asopencode2in the compiled V2 binary and remainsopencodefor source runs.packages/cli/test/service.test.tscovers a real child that exits before registration and a nonexistent spawn command. It asserts the exact rendered registration output and the retained nested cause.Scope
This PR changes managed background-service startup failure classification and CLI presentation only. It does not change compatibility detection, service election, retry duration, or service-status behavior tracked by #36274.
Fixes #35158
Testing
bun run testfrompackages/cli: 27 passed, 0 failed across 7 files.bun run test test/effect.test.ts test/contract-identity.test.ts test/import-boundaries.test.tsfrompackages/client: 9 passed, 0 failed.bun typecheckfrompackages/cli: passed.bun typecheckfrompackages/client: passed.bunx prettier --check src/index.ts src/framework/startup-error.ts test/service.test.ts ../client/src/effect/service.tsfrompackages/cli: passed.bun run build --single --skip-installfrompackages/cli: built the nativeopencode2V2 binary.120x40: the compiled child exited before registration; default output contained no stack frames, whileopencode.logretainedServiceStartError -> PlatformError -> ENOENT.bun turbo typecheck --concurrency=3: 31 tasks passed.Demo
Both screenshots use compiled V2 binaries, the same real managed-service failure, and identical
120x40terminal dimensions.Before (
9ff7df07d6)The CLI emits the generic raw failure, internal paths, and the complete Effect stack.
After (
3b03692aef)The CLI emits the actual user-facing startup failure presentation.