Skip to content

Commit 548b21f

Browse files
committed
fix: release HTTP connections after POST responses in SSE and streamableHttp transports
1 parent 6083600 commit 548b21f

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/client/sse.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ export class SSEClientTransport implements Transport {
281281

282282
throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
283283
}
284+
285+
// Release connection - POST responses don't have content we need
286+
await response.body?.cancel();
284287
} catch (error) {
285288
this.onerror?.(error as Error);
286289
throw error;

src/client/streamableHttp.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,12 @@ export class StreamableHTTPClientTransport implements Transport {
592592
this.onmessage?.(msg);
593593
}
594594
} else {
595+
await response.body?.cancel();
595596
throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType}`);
596597
}
598+
} else {
599+
// No requests in message but got 200 OK - still need to release connection
600+
await response.body?.cancel();
597601
}
598602
} catch (error) {
599603
this.onerror?.(error as Error);

0 commit comments

Comments
 (0)