fix(event-stream): cancel unavailable upstream bodies (#1142)
Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
committed by
GitHub
co-authored by
Isaac Sanchez
parent
47fc6a4606
commit
4a79af3fb7
@@ -31,6 +31,12 @@ function normalizeHeaders(headers) {
|
||||
return { ...headers };
|
||||
}
|
||||
|
||||
async function cancelResponseBody(response) {
|
||||
if (response?.body && typeof response.body.cancel === 'function') {
|
||||
await response.body.cancel().catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
export function createUpstreamSseReader({
|
||||
buildUrl,
|
||||
getHeaders = () => ({}),
|
||||
@@ -116,6 +122,7 @@ export function createUpstreamSseReader({
|
||||
status: response?.status ?? 0,
|
||||
response,
|
||||
});
|
||||
await cancelResponseBody(response);
|
||||
await waitForReconnectDelay(reconnectDelayMs, signal);
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user