fix(runner): bound server scenarios with a per-scenario timeout - #454
Open
aviseth wants to merge 1 commit into
Open
fix(runner): bound server scenarios with a per-scenario timeout#454aviseth wants to merge 1 commit into
aviseth wants to merge 1 commit into
Conversation
The client runner has had a 30s per-scenario timeout since it was written, but `runServerConformanceTest` awaited `scenario.run(ctx)` with no bound. A server under test that accepts the TCP connection and then never answers an initialize POST, a tools call, or an SSE read stalled the entire suite run, not just its own scenario. modelcontextprotocol#316 bounded the session-termination DELETEs in teardown, but that is a call-site fix: covering the rest that way needs the same treatment on every raw fetch in every scenario. Bounding at the runner makes those per-call bounds defense-in-depth instead of the only protection. `--timeout` now applies to server mode too, with the same 30s default as client mode. On expiry the scenario reports a `scenario-timeout` FAILURE naming the elapsed bound, so a wedged server reads as a failing scenario rather than a hung process. The timed-out scenario promise is left pending deliberately — a read blocked on a socket has no cancellation channel — with its rejection swallowed so a late failure can't surface against whichever scenario is running by then. Fixes modelcontextprotocol#427
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.
Closes #427.
The client runner has bounded each scenario since it was written. The server runner never did, so a server that accepts the TCP connection and then stops answering stalled the whole run instead of failing its own scenario.
--timeoutnow works in server mode, same 30s default as client mode. When it fires, the scenario gets ascenario-timeoutFAILURE naming the bound and the suite carries on.The one decision I'd like a second opinion on: the timed-out
scenario.runpromise is left pending rather than cancelled. A read blocked on a socket has nothing to cancel through, so there is nothing to await — I swallow its rejection so a late failure can't land on whatever scenario is running by then. Threading anAbortSignalthroughRunContextwould let scenarios actually tear down, but that touches every scenario and seemed like a separate change. Say the word and I'll do it that way instead.Tested by pointing
server-initializeat a server that completes the handshake and never writes a byte. With the runner change reverted the test hangs until vitest kills it at 30s. Full suite, typecheck and lint pass.#316's per-call bounds still earn their keep — they fail faster and attribute the failure better. They're just no longer the only thing between a wedged server and an unbounded run.