fix: release HTTP connections after POST responses (#1214)

Co-authored-by: Konstantin Konstantinov <KKonstantinov@users.noreply.github.com>
This commit is contained in:
Matt 2025-12-04 09:56:32 +00:00 • committed by GitHub
commit 0a374fc20a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View file

@ -281,6 +281,9 @@ export class SSEClientTransport implements Transport {
throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
}
// Release connection - POST responses don't have content we need
await response.body?.cancel();
} catch (error) {
this.onerror?.(error as Error);
throw error;

View file

@ -592,8 +592,12 @@ export class StreamableHTTPClientTransport implements Transport {
this.onmessage?.(msg);
}
} else {
await response.body?.cancel();
throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType}`);
}
} else {
// No requests in message but got 200 OK - still need to release connection
await response.body?.cancel();
}
} catch (error) {
this.onerror?.(error as Error);