Repository navigation
Closed
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
packages/contracts or packages/shared
Steps to reproduce
- Start an ACP agent turn that calls a T3 MCP tool.
- Click Stop after the tool response starts arriving as JSON but stalls before finishing.
Expected behavior
Stopping the turn closes its unfinished MCP response and releases the connection.
Actual behavior
The turn stops, but its unfinished response remains open and continues accepting body data.
Impact
Minor bug or occasional failure. ACP users retain an HTTP response and its buffered data each time they stop a call whose JSON response has stalled, so repeated stops accumulate resources until the response finishes or the connection fails.
Version or commit
main at 17c142588b. The cause is at packages/shared/src/mcpResponsePayloads.ts:61.
Environment
Linux x64, the repository's own tests.
Logs or stack traces
interrupted MCP response must stop accepting body bytesAutomated repro
Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.
diff --git a/packages/shared/src/mcpResponsePayloads.test.ts b/packages/shared/src/mcpResponsePayloads.test.ts
index a18a798e95..d3366d6715 100644
--- a/packages/shared/src/mcpResponsePayloads.test.ts
+++ b/packages/shared/src/mcpResponsePayloads.test.ts
@@ -93,31 +93,37 @@ it.effect("picks the SSE reader from the media type alone, whatever its case", (
}),
);
-it.effect("releases a stalled SSE response body when its consumer is interrupted", () =>
- Effect.gen(function* () {
- const reading = Promise.withResolvers<void>();
- let controller!: ReadableStreamDefaultController<Uint8Array>;
- const body = new ReadableStream<Uint8Array>(
- {
- start(value) {
- controller = value;
- },
- pull() {
- reading.resolve();
+it.effect.each(["text/event-stream", "application/json"])(
+ "releases a stalled %s response body when its consumer is interrupted",
+ (contentType) =>
+ Effect.gen(function* () {
+ const reading = Promise.withResolvers<void>();
+ let controller!: ReadableStreamDefaultController<Uint8Array>;
+ const body = new ReadableStream<Uint8Array>(
+ {
+ start(value) {
+ controller = value;
+ },
+ pull() {
+ reading.resolve();
+ },
},
- },
- { highWaterMark: 0 },
- );
- const response = new Response(body, { headers: { "content-type": "text/event-stream" } });
- const consumer = yield* Stream.runDrain(responsePayloads(response, String)).pipe(
- Effect.forkChild,
- );
- yield* Effect.promise(() => reading.promise);
- yield* Fiber.interrupt(consumer);
- try {
- expect(body.locked, "interrupted SSE response must release its body").toBe(false);
- } finally {
- if (body.locked) controller.close();
- }
- }),
+ { highWaterMark: 0 },
+ );
+ const response = new Response(body, { headers: { "content-type": contentType } });
+ const consumer = yield* Stream.runDrain(responsePayloads(response, String)).pipe(
+ Effect.forkChild,
+ );
+ yield* Effect.promise(() => reading.promise);
+ yield* Fiber.interrupt(consumer);
+ try {
+ expect(
+ () => controller.enqueue(new TextEncoder().encode("late response bytes")),
+ "interrupted MCP response must stop accepting body bytes",
+ ).toThrow(TypeError);
+ expect(body.locked, "interrupted MCP response must release its body").toBe(false);
+ } finally {
+ if (body.locked) controller.close();
+ }
+ }),
);cd packages/shared && pnpm exec vp test run --config ../../vite.config.ts --dir . src/mcpResponsePayloads.test.tsWorkaround
No response
Metadata
Metadata
Assignees
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Activity