Repository navigation
fix(client): time out requests after the handshake (#474) - #505
Merged
Merged
Conversation
AimxConnection bounded only the `hello` handshake; every later request awaited its reply forever, so `aimdb record get/set` and the MCP tools hung on an instance that stopped answering mid-session. - aimdb-client: each reply-awaiting call is bounded by a per-connection request timeout (DEFAULT_REQUEST_TIMEOUT, 5 s; set with `with_request_timeout`) and fails with the new `ClientError::Timeout`. The connection stays open; the engine reclaims the abandoned call and discards a late reply. Subscriptions and `write_record` are unbounded. - aimdb-cli: global `--request-timeout <SECS>` (default 5, min 1). A timeout exits 3 (environment, worth retrying). Named so it does not clash with `watch --timeout`. - aimdb-mcp: picks up the default, so a silent instance returns a tool error instead of holding the client lock indefinitely. Closes #474 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGkDJ9zFEC4MLmEkzF8fiE
The previous commit's changelog entry for aimdb-mcp described behaviour the crate got only through the client default. Make the MCP side do what the issue asks: a ClientError::Timeout from a tool now returns a ToolCallResult with isError: true and a message naming the method, so the agent can retry or report the instance as unresponsive. Other errors remain JSON-RPC errors as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGkDJ9zFEC4MLmEkzF8fiE
- aimdb-cli: replace the end-to-end silent-server test with one entry in the existing exit-code unit test (ClientError::Timeout -> exit 3); drop the clap range test. - aimdb-client: keep one typed call, one `not_found`-as-answer call (instance_info) and the still-open check; drop the redundant calls, the default-value assert, the elapsed-time bound and the message match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGkDJ9zFEC4MLmEkzF8fiE
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 #474.
Problem
AimxConnectionbounded only thehellohandshake. Every later request awaited its reply forever, soaimdb record get/setand the MCP tools hung on an instance that stopped answering mid-session (hung task, board held by a watchdog, link dropped without closing).Changes
aimdb-client
get_record,set_record,list_records,drain_record*,query,graph_*,instance_info, eachpost_linkchunk, the resets) is bounded by a per-connection request timeout:engine::DEFAULT_REQUEST_TIMEOUT(5 s), configurable viaAimxConnection::with_request_timeout.ClientError::Timeout { method, after }. The connection stays open; the engine already sweeps abandoned pending calls and discards late replies.subscribe,write_record, rawhandle().call(…).aimdb-cli
--request-timeout <SECS>(default 5, min 1), threaded through a smallTarget { endpoint, request_timeout }struct.watch --timeout.--request-timeoutrather than the issue's--timeout: a global--timeoutwould clash withwatch --timeout, which means something different.aimdb-mcp
ClientError::Timeoutfrom a tool is returned as a tool error (isError: true, text naming the method), as the issue proposes, so the agent can retry or report the instance as unresponsive. All other errors remain JSON-RPC errors as before; extending that to every client error is a follow-up.Notes for review
ClientErrorvariant is breaking for exhaustive matches (the enum isn't#[non_exhaustive]), soaimdb-clientneeds a minor bump.--ignore-rust-version(the pinned 1.98 couldn't be downloaded in my environment): tests, clippy-D warningsand fmt pass for aimdb-client, aimdb-cli and aimdb-mcp. CI on 1.98 should confirm.Tests
aimdb-client/tests/request_timeout.rs: fake server answershellothen goes silent; a typed call andinstance_infoboth fail withClientError::Timeout, and the connection still serves a request afterwards.aimdb-clierror::tests::exit_codes_follow_failure_classes: a client timeout maps to exit 3.aimdb-mcpserver::tests::a_request_timeout_is_a_tool_error: timeout →isError: true; success and other errors unchanged.https://claude.ai/code/session_01WGkDJ9zFEC4MLmEkzF8fiE
Generated by Claude Code