feat(core): report connection state on a request timeout (#2318)
A request timeout used to surface as a bare `Request timed out`. Every fact needed to explain it was already in-process: what the client was still waiting on, when it last heard back, and the state of the standalone GET notification stream. The SDK's timeout now rejects with all three, and the same snapshot is shown live in Connection Info and on the Network entry for the stream. - core/mcp/connectionDiagnostics.ts: the snapshot type, its one-line description, and `annotateRequestTimeout`, which rebuilds the SDK's per-request timeout with the state at that moment. - InspectorClient decorates the SDK Client's `request` (the one funnel every verb goes through) so the annotation covers the whole surface; tracks outstanding requests with their send time, the last response, and the most recent long-lived transport stream; exposes `getConnectionDiagnostics()` and `connectionDiagnosticsChange`. - fetchTracking watches a long-lived stream through a tee'd clone, counting SSE events and reporting the close, via a new `updateStream` callback wired through the node transport, the remote session (`fetch_stream_update`), and the browser transport. - FetchRequestLogState patches `entry.stream`; the Network entry's placeholder reports the event count and open/closed state. - Connection Info gains a Connection Activity section, ticking while open (`useTickingClock`). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01APKSYHGxXBUpnR7ErFiLJn Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
153ee7dd15
commit
d57801d7b3
1 changed files with 2315 additions and 32 deletions
|
|
@ -151,6 +151,28 @@ export class FetchRequestLogState extends TypedEventTarget<FetchRequestLogStateE
|
|||
onFetchRequestBodyUpdate,
|
||||
);
|
||||
|
||||
// A long-lived stream's lifecycle arrives the same way its sibling's
|
||||
// body does: asynchronously, patched onto the entry in place (#2318). A
|
||||
// missing entry is left silent here, unlike the body path — a stream
|
||||
// reports on every event, so after a clear the stragglers are many and
|
||||
// none of them is data the user could have wanted retained.
|
||||
const onFetchRequestStreamUpdate = (
|
||||
event: TypedEventGeneric<
|
||||
InspectorClientEventMap,
|
||||
"fetchRequestStreamUpdate"
|
||||
>,
|
||||
): void => {
|
||||
const { id, stream } = event.detail;
|
||||
const idx = this.fetchRequests.findIndex((e) => e.id === id);
|
||||
if (idx === -1) return;
|
||||
this.fetchRequests[idx] = { ...this.fetchRequests[idx]!, stream };
|
||||
this.dispatchTypedEvent("fetchRequestsChange", this.getFetchRequests());
|
||||
};
|
||||
this.client.addEventListener(
|
||||
"fetchRequestStreamUpdate",
|
||||
onFetchRequestStreamUpdate,
|
||||
);
|
||||
|
||||
const sessionStorage = options.sessionStorage;
|
||||
const sessionId = options.sessionId;
|
||||
|
||||
|
|
@ -194,6 +216,10 @@ export class FetchRequestLogState extends TypedEventTarget<FetchRequestLogStateE
|
|||
"fetchRequestBodyUpdate",
|
||||
onFetchRequestBodyUpdate,
|
||||
);
|
||||
this.client.removeEventListener(
|
||||
"fetchRequestStreamUpdate",
|
||||
onFetchRequestStreamUpdate,
|
||||
);
|
||||
this.client.removeEventListener("saveSession", onSaveSession);
|
||||
}
|
||||
this.client = null;
|
||||
|
|
@ -220,6 +246,10 @@ export class FetchRequestLogState extends TypedEventTarget<FetchRequestLogStateE
|
|||
"fetchRequestBodyUpdate",
|
||||
onFetchRequestBodyUpdate,
|
||||
);
|
||||
this.client.removeEventListener(
|
||||
"fetchRequestStreamUpdate",
|
||||
onFetchRequestStreamUpdate,
|
||||
);
|
||||
}
|
||||
this.client = null;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue