test(opencode): bound Miniflare worker startup and name its timeout - #178
Merged
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 1 file
Architecture diagram
sequenceDiagram
participant Runner as Test Runner
participant Hooks as File Lifecycle Hooks
participant Wait as Bounded Ready Helper
participant MF as Shared Miniflare Worker
participant Relay as Relay Worker
participant Upstream as Upstream Stub
Note over Runner,Upstream: Current-state relay-worker-miniflare test architecture
Runner->>Hooks: beforeAll()
Hooks->>MF: Create one worker instance
MF->>MF: Start workerd process
Hooks->>Wait: Await worker readiness with 90s budget
Wait->>MF: Await ready
MF-->>Wait: Worker URL
Wait-->>Hooks: Ready
Hooks-->>Runner: Test file initialized
loop Each relay test
Runner->>Wait: Await shared worker readiness
Wait->>MF: Await ready with bounded timeout
MF-->>Wait: Worker URL
Wait-->>Runner: Ready URL
alt HTTP relay path
Runner->>Relay: sendViaRelay(HTTP, token, auth, affinity, body)
Relay->>MF: HTTP request
MF->>Upstream: Forward request and headers
Upstream-->>MF: Response and quota headers
MF-->>Relay: Relay response
Relay-->>Runner: Response
else WebSocket relay path
Runner->>Relay: sendViaRelay(WebSocket, token, auth, affinity, body)
Relay->>MF: Connect to worker WebSocket
MF->>Upstream: Forward full_sync or patch request
Upstream-->>MF: Response and quota headers
MF-->>Relay: WebSocket control messages
Relay-->>Runner: Reconstructed response
end
end
alt Worker startup exceeds readiness budget
Wait-->>Runner: Error: Miniflare worker startup timed out under load (issue #176) - not a websocket-logic failure
else Deterministic never-ready check
Runner->>Wait: Await never-ready stub with 1ms budget
Wait-->>Runner: Named startup timeout error
end
Runner->>Hooks: afterAll()
Hooks->>MF: Dispose shared worker
MF->>MF: Stop workerd process
Hooks-->>Runner: File resources released
Note over Wait: Readiness timer is cleared when the race settles
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
iceteaSA
force-pushed
the
fix/miniflare-ready-bound
branch
from
September 1, 2026 13:39
041d4ad to
4fc2bf8
Compare
There was a problem hiding this comment.
All reported issues were addressed across 1 file (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
iceteaSA
force-pushed
the
fix/miniflare-ready-bound
branch
from
September 2, 2026 07:28
7486921 to
cfab9a9
Compare
rustybret
pushed a commit
to rustybret/anthropic-auth
that referenced
this pull request
Sep 2, 2026
cb282b0 feat(core): publish per-field quota provenance in the header feed (cortexkit#172) f83cf4a test(opencode): bound Miniflare worker startup and name its timeout (cortexkit#178)
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.
Fixes #176.
relay-worker-miniflare.test.tsfails on shared runners with a 30s timeout andworkerd ... Broken pipe, hitting a different test in the file each time — three CI hits on one branch today (runs 33495627135, 33508661808, 33509080794), while solo runs pass 4/0 in under a second every time. The websocket logic was never the problem: each of the four tests constructed and awaited its own Miniflare instance inside the per-test 30s budget, so worker startup contention under parallel suite load ate the timeout and misattributed the failure to whichever test ran.Two changes, both from the issue:
beforeAllwith its own 90s hook timeout and disposed inafterAll. Startup no longer competes with (or bills against) any test's budget, and three of the four startups disappear entirely.readyawait goes through a bounded helper that throwsMiniflare worker startup timed out under load (issue #176) — not a websocket-logic failureon expiry. If a runner is ever slow enough to blow a 90s startup budget, the failure now says what it is instead of masquerading as a websocket assertion.The timer is cleared once the race settles, so the loser can't fire into a later test.
Verification: solo run 5/0 (the fifth is a new deterministic test driving the helper with a 1ms budget against a never-ready stub and asserting the named error). Full root suite 3/3 green post-fix with the miniflare file passing all three. Honest caveat: the load-dependent failure would not reproduce on demand in a pre-fix baseline (two runs) — it never does when you want it to — so acceptance rests on the deterministic named-error path plus the 3× green, not on a reproduced red.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Fixes #176. Makes
relay-worker-miniflare.test.tsreliable on shared CI runners by sharing one Miniflare instance per file and bounding startup with a self-describing timeout. Previously, each test started its own worker inside the 30s test budget, so startup contention on parallel runners blew the timeout and got misattributed to whichever test ran.beforeAllwith a dedicated 90s hook timeout, then disposes it inafterAll; tests assert only the upstream bodies they added, since bodies accumulate on the shared instance.readyawait through a bounded helper that throws a named error on expiry instead of surfacing as a websocket assertion, and disposes timed-out workers so cleanup preserves that error.Written for commit cfab9a9. Summary will update on new commits.