fix(e2e): stop the cap-eviction scenario from stampeding cold DO starts - #1895
Open
ra-co88 wants to merge 1 commit into
Open
fix(e2e): stop the cap-eviction scenario from stampeding cold DO starts#1895ra-co88 wants to merge 1 commit into
ra-co88 wants to merge 1 commit into
Conversation
This was referenced Aug 30, 2026
ra-co88
force-pushed
the
fix/e2e-cap-eviction-thundering-herd
branch
from
August 30, 2026 21:03
71f05c6 to
3a0b881
Compare
The scenario opened cap+10 sessions at concurrency 8, and every open is a cold Durable Object start (sqlite open plus runtime construction inside the agents SDK blockConcurrencyWhile). The burst regularly made those blocks outlive the runtime wall-clock budget, so workerd reset the object mid-initialize and the client received the 503 restart envelope instead of an mcp-session-id header - the scenario then failed on the very first reset. Fails on main today. Two changes, root cause first: - Open at concurrency 2. Cold starts no longer overlap into reset territory; the scenario passes in ~5s locally, 4/4 consecutive runs. - openSession now honors the restart envelope it can receive: on the documented 503 "MCP session is restarting, please retry" response it retries the same initialize after a short delay (bounded, 8 attempts) instead of treating a retryable platform blip as a setup failure - the same contract a real streamable-http client follows.
ra-co88
force-pushed
the
fix/e2e-cap-eviction-thundering-herd
branch
from
August 30, 2026 21:14
3a0b881 to
d4da0e5
Compare
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
Fixes the
E2E (cloud 13of16)shard failure that's been red on main:cloud/mcp-session-cap-eviction.test.tsfailing withopenSession (session-N): no mcp-session-id header.Why it fails
The scenario opens
cap + 10sessions at concurrency 8 to force a resident-runtime cap eviction. Every open is a cold Durable Object start — sqlite open plus runtime construction inside the agents SDK'sblockConcurrencyWhile. Under that burst the start-up block regularly outlives workerd's wall-clock budget for it, and the platform resets the object mid-initialize. The in-flightinitializethen surfaces as the restart envelope (503, JSON-RPC -32001, "MCP session is restarting, please retry") instead of a response carryingmcp-session-id— and the test failed on the very first one instead of honoring it.Server-side evidence from a local repro: the dev server's log showed
concurrency_resetplatform failures for nearly every session in the burst, each correctly answered with the retryable 503 envelope byagent-handler's classifier.What changed
Two changes, root cause first:
Effect.forEach. Cold DO stops overlapping into reset territory. The scenario goes from a guaranteed failure (180s timeout or first-reset throw) to a ~5s pass.openSessionhonors the restart envelope. On the documented 503 "MCP session is restarting, please retry" response it retries the sameinitializeafter a short delay (bounded, 8 attempts) instead of treating a retryable platform blip as a setup precondition failure — the same contract a real streamable-http client follows. Kept as a backstop for the occasional reset that still slips through.Verification
mcp-priming-reconnect,session-gate) still green.oxlintandtsc --noEmitclean on the touched package.