Repository navigation
fix(opencode): give opencode serve a startup budget that survives a loaded machine - #1367
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ling it at 10 s The package's serve readiness default (10 s) was sized for an idle machine. Measured on the bundled binary, a healthy server reported its URL in 0.6-0.9 s idle but 16.7-43.1 s under load, so orchestration's OpenCode agents failed to spawn. The app owns the process and now passes a 120 s wait; a server that dies still fails at once. Refs #1355 (the orchestration bridge deadline is #1370) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Juliusolsson05
force-pushed
the
fix/opencode-serve-startup-under-load
branch
from
September 27, 2026 06:50
85abb7e to
bdfa24b
Compare
#1367 review b: a fixed 30 s test budget could fail on a loaded runner while the app (120 s) would still be waiting. The positive cases now follow OPENCODE_SERVE_STARTUP_TIMEOUT_MS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… rollback #1367 review c: a 1_200_000 constant and removing the rollback's headless.stop() both left every test green. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Review disposition. Round 1: a FIX-BEFORE-MERGE, b MERGE-READY, c (pi) MERGE-READY. Verification of a: FIX-BEFORE-MERGE in round 2 (one new blocker), then MERGE-READY in round 3. Scoped out and filed
Fixed
🤖 Generated with Claude Code |
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.
Refs #1355. This fixes the
opencode servestartup timeout. Orchestration children whose start takes over 30 s still hit the orchestration bridge's owncreate-agentdeadline, so #1355 stays open until #1370 lands.Plan:
docs/plans/2026-09-27-opencode-serve-startup-under-load.md(first commit).Problem
orchestration_create_agentwith kindopencodefailed repeatedly under load: 3 times from 3 workers in about an hour, and twice more for my own reviewers. Each failure read "Timed out waiting for …/opencode serve to report its URL". The only deadline on this path isSpawnedServer's package default of 10 s. The app never passed its own, and nothing in the app wrapsheadless.start()in another deadline.Evidence
Reproduced on the real bundled binary (OpenCode 1.18.31), timing
opencode serve --port 0until its listen line:The server was healthy but starved; the fixed wall-clock deadline was what killed it.
What merges
OpencodeSessionpassesstartupTimeoutMs: OPENCODE_SERVE_STARTUP_TIMEOUT_MS(120 s) toOpencodeHeadless. The app owns the process and the package already takes the option, so this needs no package change.Not in this PR
create-agentdeadline (bug(orchestration): a child whose provider starts in >30 s is adopted without its bootstrap prompt #1370). It is shared by every provider. A start slower than 30 s makes the create outcome unknown, and the late-adopted child gets no bootstrap prompt. Fixing it means choosing between late bootstrap delivery and MCP clients' own tool-call timeouts. With this PR, a start of 10–30 s now succeeds through orchestration too; two of the three recorded contended starts took 16.7 and 18.3 s.Tests
opencodeSession.readiness.test.ts: the spawned headless gets the startup wait, and the wait is between two and four times the worst measured healthy start, and a start that rejects stops the server it spawned.opencodeServeStartup.system.test.ts: the realSpawnedServerand a real child process, where a stubopencodeprints OpenCode's listen line 11 s late. It becomes ready under the app's wait, and it is rejected under the package default: the exact failure users hit.opencodeServeStartup.system.test.ts, through the package:OpencodeHeadlessforwards the app's wait to the spawned serve, and dropping that forwarding fails the test (review a).8f7a5ec6(main merged),npx tsc -bis clean and both suites pass. The slow-serve system tests wait as long as the app does.🤖 Generated with Claude Code