fix: release HTTP connections after POST responses (#1214)
Co-authored-by: Konstantin Konstantinov <KKonstantinov@users.noreply.github.com>
This commit is contained in:
parent
2d2c8ffaab
commit
0a374fc20a
2 changed files with 7 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue