Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/e2e/scenarios/protocol.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,12 +662,15 @@ verifies('protocol:timeout:basic', async ({ transport }: TestArgs) => {
verifies('protocol:timeout:max-total', async ({ transport }: TestArgs) => {
vi.useFakeTimers();
try {
let markCallReceived!: () => void;
const callReceived = new Promise<void>(resolve => (markCallReceived = resolve));
const makeServer = () => {
const s = new McpServer({ name: 's', version: '0' });
s.registerTool(
'slow-progress',
{ inputSchema: z.object({ delayMs: z.number(), steps: z.number() }) },
async ({ delayMs, steps }, ctx) => {
markCallReceived();
const token = ctx.mcpReq._meta?.progressToken;
if (token !== undefined) {
for (let i = 1; i <= steps; i++) {
Expand Down Expand Up @@ -703,6 +706,18 @@ verifies('protocol:timeout:max-total', async ({ transport }: TestArgs) => {
);
call.catch(() => {});

// Over SSE the tools/call POST is real I/O that fake timers do not wait for.
// Advancing before it lands lets the per-request timeout fire before any
// progress is sent, so maxTotalTimeout is never exercised (#3045). Awaiting a
// promise, unlike vi.waitFor, does not move the fake clock. If the call settles
// without reaching the handler (e.g. its arguments are rejected), fail with
// that reason instead of waiting on callReceived until the test times out.
const settledFirst = call.then(() => {
throw new Error('tools/call settled before the tool handler ran');
});
settledFirst.catch(() => {});
await Promise.race([callReceived, settledFirst]);

for (let elapsed = 0; elapsed < maxTotal + perChunk; elapsed += delayMs) {
await vi.advanceTimersByTimeAsync(delayMs);
}
Expand Down
Loading