feat: bound connect attempts with a 30 s default connectionTimeout (#2320)

connectionTimeout defaulted to 0, which InspectorClient.connect() read as
"no bound at all" — so out of the box nothing the Inspector owns bounded a
connect attempt, and the only thing ending a hung handshake was the SDK's
60 s per-request timeout on initialize, reporting "Request timed out".

- Add DEFAULT_CONNECTION_TIMEOUT_MS (30000) to core/mcp/types.ts. An absent
  value resolves to it on the client, on disk read, in the web form draft,
  and in the CLI's header-only settings shell. An explicit 0 keeps its
  documented meaning (no timeout; --connect-timeout 0) and is now persisted
  so the opt-out round-trips; the default is the omit-sentinel, as for
  taskTtl.
- Key the post-timeout transport teardown to the timer actually firing, not
  to connectionTimeout > 0 — otherwise a non-zero default would tear down
  every failed connect, including a recoverable 401 whose transport the
  auth recovery holds open.
- The timeout message names the bound and where to raise it: "Connection
  timed out after N ms. To accommodate a slower server, you may increase
  the timeout value in Server Settings."
- The CLI's UNREACHABLE classifier now matches that message.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M4h8Xa6Ed9zwtv5ojX35MT
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-09-13 20:54:23 -04:00
commit e641edeeab

View file

@ -6,6 +6,7 @@
*/
import {
DEFAULT_CONNECTION_TIMEOUT_MS,
DEFAULT_MAX_FETCH_REQUESTS,
DEFAULT_MODERN_LOG_LEVEL,
DEFAULT_PROTOCOL_ERA,
@ -533,9 +534,13 @@ export function storedFieldsToInspectorSettings(
headers: headersPairs,
env: envRecordToPairs(stored.env),
metadata: normalizeStoredMetadata(stored.metadata),
connectionTimeout: stored.connectionTimeout ?? 0,
// Concrete product default, like taskTtl below: an absent field reads back
// as 30 s so the form shows the bound that will actually apply. An explicit
// 0 is preserved as-is — it is the user's opt-out, not a sentinel (#2320).
connectionTimeout:
stored.connectionTimeout ?? DEFAULT_CONNECTION_TIMEOUT_MS,
requestTimeout: stored.requestTimeout ?? 0,
// Unlike the timeouts (0 = "SDK default"), task TTL has a concrete product
// Unlike requestTimeout (0 = "SDK default"), task TTL has a concrete product
// default so the form shows it and "Run as task" has a value to send.
taskTtl: stored.taskTtl ?? DEFAULT_TASK_TTL_MS,
autoRefreshOnListChanged: stored.autoRefreshOnListChanged ?? false,
@ -659,7 +664,11 @@ export function inspectorSettingsToStoredFields(
out.metadata = settings.metadata;
}
if (settings.connectionTimeout > 0) {
// The product default is the omit-sentinel (as for taskTtl below), so a file
// that never named a timeout stays byte-stable. Anything else persists —
// including 0, which is now a non-default the user chose (no timeout) and
// would otherwise silently read back as 30 s on the next load (#2320).
if (settings.connectionTimeout !== DEFAULT_CONNECTION_TIMEOUT_MS) {
out.connectionTimeout = settings.connectionTimeout;
}
if (settings.requestTimeout > 0) {