You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The stdio test server now accepts --crashable (via getCrashableTestMcpServerCommand()). In that mode it serves the default config plus:
crash_server (createCrashServerTool()), which exits the process at a point the test chooses:
respond: false (the default) exits without answering, so the call and anything else in flight is still outstanding when the process dies.
respond: true answers first and exits delayMs later, so the crash lands on an idle session.
stderr writes a message before exiting. The exit waits for stderr and stdout to flush first, because pipe writes are async on macOS.
collect_elicitation and collect_sample, so a test can have a peer request pending at the moment of the crash.
The tool exists only on the spawned stdio entry and is deliberately absent from the presets: it calls process.exit, so wiring it into an in-process server would end the test runner.
These drive a real process death through the onclose teardown route in attachTransportListeners. Until now that route was only reached by unit tests calling onclose on a fake transport. Cases:
Idle crash: status settles to disconnected and disconnect fires exactly once. A follow-up disconnect() does not announce it again.
Call in flight: the call rejects with Connection closed.
Pending elicitation / pending sampling: the queue is cleared, and its …Change([]) event fires beforedisconnect. A disconnect listener sees both queues empty.
Stderr on the way down: the server's dying words are captured.
Reconnect: the same client reconnects to a fresh process and can be crashed and reconciled again. The crash route leaves the transport object cached, and this confirms the SDK's stdio transport restarts through it.
Docs: the test-servers skill (the spawned-stdio section said no variant could be selected) and docs/test-servers.md.
Not covered
Hang mode. The issue mentions "crash/hang". A server that stops answering while its process stays alive goes down the request-timeout path, not the reconciliation route; inspectorClient-timeout-diagnostics.test.ts covers that, so there is no hang mode.
Mutation check: deleting clearAndAnnouncePendingPeerRequests() from onclose fails the elicitation and sampling cases.
npm run local:gate is green. It was run with the sandbox's HTTP(S)_PROXY variables unset: with them set, 18 tests in server-extra-coverage and node/transport fail with Proxy response (502) … HTTP Tunneling, and they all pass once the variables are unset. That is an environment problem unrelated to this change.
… reconciliation
The transport `onclose` route in InspectorClient — settle the status, drop
and announce queued sampling/elicitation requests before `disconnect`,
reject what we asked the server, fire `disconnect` once — was only reached
by unit tests calling `onclose` on a fake transport.
The stdio test server now takes `--crashable`
(`getCrashableTestMcpServerCommand()`), which adds a `crash_server` tool
that exits the process at a point the test picks: with the call in flight,
or after answering on an idle session, optionally writing to stderr first.
It lives only on the spawned stdio entry because it calls `process.exit`.
The new integration suite drives a real process death through: idle
crash, in-flight call rejection, pending elicitation and sampling cleared
and announced before `disconnect`, stderr dying words captured, and
reconnecting the same client to a fresh process.
Closes#2437
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
respond: true exited on a timer without waiting for the answer it had
just written to stdout, so on a platform with asynchronous pipe writes
(macOS) the process could die before the client received it — turning
the idle-session crash back into a crash with the call in flight. Put an
empty-write barrier on stdout ahead of the exit, as stderr already had.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
Wait for stdout to flush before exiting in respond mode: fixed. crash_server now puts an empty-write flush barrier on stdout before process.exit, so the respond: true answer can't be lost on platforms with async pipe writes. Replied in the thread.
There was nothing in Suppressed comments. local:gate is green again. Requesting round 2.
Add coverage for non-default crash_server exit codes
test-servers/src/test-server-stdio.ts:89
The new exitCode branch is not exercised by the crash-reconciliation suite: every crash_server call omits it, so all subprocesses still exit with the default code. Because this is an advertised fixture control, a regression that ignores or mishandles a requested code would pass. Add a subprocess-level test that invokes a non-default code and asserts the child's exit status, or remove the unsupported option.
Update comment to reflect command-line config selection
test-servers/src/test-server-stdio.ts:255
This conditional means the standalone entry no longer always starts with the default config, so the preceding “start with default config” comment is now inaccurate. Update it to mention selecting the default or crashable config from the command-line flag.
Nothing in the Inspector observes a stdio server's exit code — the
transport's onclose fires the same either way — so the option was
surface no test could give a reason to exercise. The process always
exits 1. Also corrects the standalone entry's comment, which still said
it always starts on the default config.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
Copilot round 2: no inline findings; two items in Previously missed, both addressed in c03fd53. Neither has a thread to reply in, so this comment is the answer.
Add coverage for non-default crash_server exit codes: I took the review's alternative and removed the exitCode option. Nothing in the Inspector observes a stdio server's exit code: the transport's onclose fires the same either way, so no reconciliation test could have a reason to vary it. The process now always exits 1. I updated the PR body to match.
Update the stale comment on the standalone entry: fixed. It now says the entry starts the default config, or the crashable one when --crashable is passed.
local:gate is green. The one red run in between was server-auto-open.test.ts losing a port race, which isn't touched by this PR; I filed it as #2602. Requesting round 3.
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
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 #2437
What changed
Fixture:
test-servers/src/test-server-stdio.tsThe stdio test server now accepts
--crashable(viagetCrashableTestMcpServerCommand()). In that mode it serves the default config plus:crash_server(createCrashServerTool()), which exits the process at a point the test chooses:respond: false(the default) exits without answering, so the call and anything else in flight is still outstanding when the process dies.respond: trueanswers first and exitsdelayMslater, so the crash lands on an idle session.stderrwrites a message before exiting. The exit waits for stderr and stdout to flush first, because pipe writes are async on macOS.collect_elicitationandcollect_sample, so a test can have a peer request pending at the moment of the crash.The tool exists only on the spawned stdio entry and is deliberately absent from the presets: it calls
process.exit, so wiring it into an in-process server would end the test runner.Tests:
clients/web/src/test/integration/mcp/inspectorClient-crash-reconciliation.test.tsThese drive a real process death through the
oncloseteardown route inattachTransportListeners. Until now that route was only reached by unit tests callingoncloseon a fake transport. Cases:disconnectedanddisconnectfires exactly once. A follow-updisconnect()does not announce it again.Connection closed.…Change([])event fires beforedisconnect. Adisconnectlistener sees both queues empty.Docs: the
test-serversskill (the spawned-stdio section said no variant could be selected) anddocs/test-servers.md.Not covered
inspectorClient-timeout-diagnostics.test.tscovers that, so there is no hang mode.onerrorvsoncloseordering (Mid-session crash leaves ordering-dependent terminal status (onclose can downgrade "error" → "disconnected") #1490). A stdio process exit fires onlyonclose, so the existing mocked tests remain the coverage for that ordering.Verification
clearAndAnnouncePendingPeerRequests()fromonclosefails the elicitation and sampling cases.npm run local:gateis green. It was run with the sandbox'sHTTP(S)_PROXYvariables unset: with them set, 18 tests inserver-extra-coverageandnode/transportfail withProxy response (502) … HTTP Tunneling, and they all pass once the variables are unset. That is an environment problem unrelated to this change.🤖 Generated with Claude Code