fix(client): surface managed startup stderr - #41793
Merged
Merged
Conversation
kitlangton
marked this pull request as ready for review
August 12, 2026 00:39
# ------------------------ >8 ------------------------ # Do not modify or remove the line above. # Everything below it will be ignored. # # Conflicts: # packages/client/src/effect/service.ts # packages/client/src/promise/service.ts
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
Surface actionable stderr when a managed background-service contender exits unsuccessfully. This lets
opencode2 service startreport the existing port-conflict guidance instead of reducing it to an exit code.Closes #41696
Before / After
Before:
serve --serviceemitted the actionable port-conflict diagnostic, butService.ensurespawned it withstdio: "ignore". The managed client saw onlyServer process exited with code 1and could continue spawning contenders without exposing the cause.After: managed contenders continuously retain only the final 8 KiB of stderr. Once a contender closes with a nonzero exit or signal, its startup error includes that tail, so the configured-port remediation reaches the caller.
How
packages/client/src/effect/service.tscaptures a bounded stderr tail and waits for childcloseso output is drained before formatting failures.packages/client/src/promise/service.tsmirrors the same behavior without adding an Effect runtime dependency.Service.ensureboundary using the same actionable conflict text.Scope
Testing
cd packages/client && bun run test test/service.test.ts test/promise-service.test.ts(21 passed)cd packages/cli && bun run test test/service.test.ts --test-name-pattern "managed service startup reports an actionable port conflict|unrelated managed port occupancy reports an actionable conflict"(2 passed)cd packages/client && bun typecheckcd packages/cli && bun typecheckbunx prettier --check packages/client/src/effect/service.ts packages/client/src/promise/service.ts packages/client/test/service.test.ts packages/client/test/promise-service.test.ts packages/client/test/fixture/service.ts packages/cli/test/service.test.tsbun turbo typecheck --concurrency=3(33 tasks passed)Flow
sequenceDiagram participant Client as Service.ensure participant Child as serve --service contender Client->>Child: spawn detached with stderr pipe Child-->>Client: stderr chunks Client->>Client: retain final 8 KiB Child-->>Client: close with nonzero exit Client-->>Client: append stderr tail to startup error