* fix(core): trace dropped fetch body update when entry rotates out (#1390) FetchRequestLogState.onFetchRequestBodyUpdate silently dropped a deferred response-body update when the matching entry had already been evicted by log rotation (>= maxFetchRequests newer requests appended between the append and the fire-and-forget body read). The user saw an empty Response Body with no way to distinguish "body never came back" from "body dropped after eviction". Plumb an optional pino logger into FetchRequestLogState (defaulting to the silent logger) and emit a logger.debug at the early-return site so the drop is traceable. The web client wires the existing remote logger from createWebEnvironment into the state manager. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(core): emit dropped-body trace at warn level so it is observable (#1390) Review feedback: the web remote logger (createRemoteLogger) defaults to level 'info' with no override at the environmentFactory call site, so a logger.debug at the drop site is filtered out by both the pino level gate and transmit.level — the diagnostic never reaches /api/log and the drop stays invisible in the shipped web app, defeating the issue's goal. Promote the trace to logger.warn (>= info, so it transmits by default). A response body lost to log rotation is unexpected data loss, not routine diagnostic noise, so warn is the appropriate severity. Update the comment to explain the level choice and switch the test stub from debug to warn, extracting a small typed makeWarnLogger helper per review. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(web): configurable Network Log Size per server + body-dropped toast (#1390) Turn the otherwise-invisible "response body dropped after rotation" case into an actionable signal: 1. Per-server `maxFetchRequests` setting (default 1000, 0 = unlimited), editable as "Network Log Size" in the first (Options) accordion section of the Server Settings form. Plumbed through the full settings pipeline: InspectorServerSettings + StoredMCPServer types, the serverList disk converters (read defaults to 1000, write omits the default to keep diffs minimal — 0 is a meaningful non-default), and the node server's GET-sanitize + write-side validateSettings (non-negative number). Applied live to the active connection on settings-modal close via a new FetchRequestLogState.setMaxFetchRequests (shrinking trims immediately), and at connect time for the next session. 2. FetchRequestLogState now emits a `fetchRequestBodyDropped` event, but only for genuine rotation drops (log at capacity with a finite cap) — not for benign post-clear stragglers or unlimited logs, which previously also hit the warn path. App shows a deduped, persistent toast (stable per-server id, no auto-close) explaining what happened and the likely causes, with a link that opens this server's settings on the Options section (modal remounts via key) so the user can raise the limit if it's just a high-traffic server. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(web): don't treat a cleared Network Log Size field as unlimited (#1390) Review feedback: clearing the NumberInput emits "", and `parseInt("") || 0` coerced that to 0 (unlimited). Since the value applies live on modal close, a user who cleared the field to retype and then closed the modal would silently switch the log to unlimited. Fall back to the current value on an empty/NaN parse and reserve 0 for an explicit numeric entry. Adds a cleared-input test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ef921ba052
commit
53dc4549be
1 changed files with 717 additions and 13 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
Anchor,
|
||||
List,
|
||||
Stack,
|
||||
Text,
|
||||
useComputedColorScheme,
|
||||
|
|
@ -36,7 +37,10 @@ import type {
|
|||
ServerEntry,
|
||||
ServerType,
|
||||
} from "@inspector/core/mcp/types.js";
|
||||
import { DEFAULT_TASK_TTL_MS } from "@inspector/core/mcp/types.js";
|
||||
import {
|
||||
DEFAULT_MAX_FETCH_REQUESTS,
|
||||
DEFAULT_TASK_TTL_MS,
|
||||
} from "@inspector/core/mcp/types.js";
|
||||
import {
|
||||
API_SERVER_ENV_VARS,
|
||||
INSPECTOR_API_TOKEN_GLOBAL,
|
||||
|
|
@ -53,6 +57,7 @@ import {
|
|||
} from "@inspector/core/mcp/serverList.js";
|
||||
import { MessageLogState } from "@inspector/core/mcp/state/messageLogState.js";
|
||||
import { FetchRequestLogState } from "@inspector/core/mcp/state/fetchRequestLogState.js";
|
||||
import type { FetchRequestLogStateEventMap } from "@inspector/core/mcp/state/fetchRequestLogState.js";
|
||||
import { StderrLogState } from "@inspector/core/mcp/state/stderrLogState.js";
|
||||
import type { RedirectUrlProvider } from "@inspector/core/auth/index.js";
|
||||
import {
|
||||
|
|
@ -279,9 +284,53 @@ const EMPTY_SETTINGS: InspectorServerSettings = {
|
|||
requestTimeout: 0,
|
||||
taskTtl: DEFAULT_TASK_TTL_MS,
|
||||
autoRefreshOnListChanged: false,
|
||||
maxFetchRequests: DEFAULT_MAX_FETCH_REQUESTS,
|
||||
roots: [],
|
||||
};
|
||||
|
||||
// Stable toast id for the "response body dropped" warning, keyed per server so
|
||||
// a request storm updates one persistent toast rather than stacking thousands
|
||||
// (the drop event can fire rapidly). Mirrors the progress-toast dedupe pattern.
|
||||
function bodyDroppedToastId(serverId: string): string {
|
||||
return `fetch-body-dropped-${serverId}`;
|
||||
}
|
||||
|
||||
// Body of the "response body dropped" warning toast: a one-line summary of what
|
||||
// happened, the likely causes, and a link that opens this server's settings
|
||||
// (on the Options section) so the user can raise the Network Log Size if it's
|
||||
// just a high-traffic server. Surfaces the otherwise-invisible rotation drop
|
||||
// described in #1390.
|
||||
const FetchBodyDroppedToastMessage = ({
|
||||
maxFetchRequests,
|
||||
onAdjust,
|
||||
}: {
|
||||
maxFetchRequests: number;
|
||||
onAdjust: () => void;
|
||||
}) => (
|
||||
<Stack gap={4}>
|
||||
<Text size="sm">
|
||||
A response body arrived after its Network log entry had already rotated
|
||||
out (the log hit its {maxFetchRequests}-request limit), so the body
|
||||
couldn't be shown. This usually indicates:
|
||||
</Text>
|
||||
<List size="sm" spacing={2}>
|
||||
<List.Item>
|
||||
a chatty or misbehaving server (notification storms, rapid polling)
|
||||
</List.Item>
|
||||
<List.Item>an SSE/transport reconnect or retry storm</List.Item>
|
||||
<List.Item>
|
||||
a slow streaming call racing against high request volume
|
||||
</List.Item>
|
||||
<List.Item>
|
||||
the Network Log Size set too low for this server's traffic
|
||||
</List.Item>
|
||||
</List>
|
||||
<Anchor component="button" type="button" size="sm" onClick={onAdjust}>
|
||||
Adjust Network Log Size for this server
|
||||
</Anchor>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
// Body of the output-schema-mismatch warning toast: a one-line summary plus a
|
||||
// link that opens the full validation details in a modal (the raw error is far
|
||||
// too long for a toast).
|
||||
|
|
@ -645,6 +694,50 @@ function App() {
|
|||
);
|
||||
const { messages } = useMessageLog(messageLogState);
|
||||
const { fetchRequests } = useFetchRequestLog(fetchRequestLogState);
|
||||
|
||||
// Surface the otherwise-invisible "response body dropped after rotation" case
|
||||
// (#1390) as a deduped toast that links to this server's Network Log Size
|
||||
// setting. The state manager only emits this when the drop is genuinely due
|
||||
// to rotation (log at capacity), not for benign post-clear stragglers.
|
||||
useEffect(() => {
|
||||
if (!fetchRequestLogState || activeServerId === undefined) return;
|
||||
const onBodyDropped = (
|
||||
event: TypedEventGeneric<
|
||||
FetchRequestLogStateEventMap,
|
||||
"fetchRequestBodyDropped"
|
||||
>,
|
||||
) => {
|
||||
notifications.show({
|
||||
id: bodyDroppedToastId(activeServerId),
|
||||
title: "Network log: response body dropped",
|
||||
color: "yellow",
|
||||
// Stays until dismissed (or the user opens settings via the link) so a
|
||||
// single toast represents an ongoing condition rather than flashing per
|
||||
// drop; the stable id dedupes a storm into this one toast.
|
||||
autoClose: false,
|
||||
message: (
|
||||
<FetchBodyDroppedToastMessage
|
||||
maxFetchRequests={event.detail.maxFetchRequests}
|
||||
onAdjust={() => {
|
||||
notifications.hide(bodyDroppedToastId(activeServerId));
|
||||
setSettingsModalTargetId(activeServerId);
|
||||
}}
|
||||
/>
|
||||
),
|
||||
});
|
||||
};
|
||||
fetchRequestLogState.addEventListener(
|
||||
"fetchRequestBodyDropped",
|
||||
onBodyDropped,
|
||||
);
|
||||
return () => {
|
||||
fetchRequestLogState.removeEventListener(
|
||||
"fetchRequestBodyDropped",
|
||||
onBodyDropped,
|
||||
);
|
||||
};
|
||||
}, [fetchRequestLogState, activeServerId]);
|
||||
|
||||
// Server-initiated sampling / elicitation requests. These arrive while a call
|
||||
// (e.g. a tool execution) is in flight and block it until the user responds.
|
||||
const { pendingSamples, pendingElicitations } =
|
||||
|
|
@ -1133,7 +1226,7 @@ function App() {
|
|||
fetchRequestLogState?.destroy();
|
||||
stderrLogState?.destroy();
|
||||
|
||||
const { environment } = createWebEnvironment(
|
||||
const { environment, logger } = createWebEnvironment(
|
||||
getAuthToken(),
|
||||
redirectUrlProvider,
|
||||
onBeforeOAuthRedirect,
|
||||
|
|
@ -1221,6 +1314,9 @@ function App() {
|
|||
// reads the current log.
|
||||
const nextFetchLog = new FetchRequestLogState(client, {
|
||||
sessionStorage: sessionStorageAdapter,
|
||||
logger,
|
||||
maxFetchRequests:
|
||||
savedSettings?.maxFetchRequests ?? DEFAULT_MAX_FETCH_REQUESTS,
|
||||
...(sessionId && { sessionId }),
|
||||
});
|
||||
fetchLogRef.current = nextFetchLog;
|
||||
|
|
@ -2122,6 +2218,11 @@ function App() {
|
|||
// effect without a reconnect (#1444). Connection-time inputs (transport,
|
||||
// OAuth, timeouts) still only apply on the next connect.
|
||||
inspectorClient.setServerSettings(settingsDraft);
|
||||
// Resize the Network log buffer live so a maxFetchRequests edit takes
|
||||
// effect without a reconnect (shrinking trims immediately). Connect-time
|
||||
// construction also reads this, so a reconnect would apply it anyway —
|
||||
// this just makes the toast→adjust flow responsive.
|
||||
fetchLogRef.current?.setMaxFetchRequests(settingsDraft.maxFetchRequests);
|
||||
const nextRoots = cleanRoots(settingsDraft.roots);
|
||||
const currentRoots = cleanRoots(inspectorClient.getRoots());
|
||||
if (JSON.stringify(nextRoots) !== JSON.stringify(currentRoots)) {
|
||||
|
|
@ -2357,6 +2458,10 @@ function App() {
|
|||
onSubmit={onConfigSubmit}
|
||||
/>
|
||||
<ServerSettingsModal
|
||||
// Remount per open (and per target server) so the accordion resets to
|
||||
// its initial "options" section — the body-dropped toast deep-links
|
||||
// here expecting the Network Log Size control to be visible.
|
||||
key={settingsModalTargetId ?? "closed"}
|
||||
opened={settingsModalTargetId !== undefined}
|
||||
settings={settingsModalValue}
|
||||
onClose={onSettingsModalClose}
|
||||
|
|
|
|||
Loading…
Reference in a new issue