Skip to content

Commit 3a117ee

Browse files
committed
fix incorrect destroy of http connection
1 parent 0845cd9 commit 3a117ee

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/extension/completions-core/vscode-node/lib/src/openai/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ export class LiveOpenAIFetcher extends OpenAIFetcher {
738738
try {
739739
// Destroy the stream so that the server is hopefully notified we don't want any more data
740740
// and can cancel/forget about the request itself.
741-
responseStream.destroy();
741+
await responseStream.destroy();
742742
} catch (e) {
743743
this.instantiationService.invokeFunction(acc => logger.exception(acc, e, `Error destroying stream`));
744744
}

src/platform/nesFetch/common/responseStream.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ export class ResponseStream {
7070
/**
7171
* @throws client of the method should handle the error
7272
*/
73-
public destroy(): void {
74-
const body = this.fetcherResponse.body();
73+
public async destroy(): Promise<void> {
74+
const body = await this.fetcherResponse.body();
7575
// Destroy the stream so that the server is hopefully notified we don't want any more data
7676
// and can cancel/forget about the request itself.
77-
if (body && 'destroy' in body && typeof body.destroy === 'function') {
78-
(body as unknown as ClientHttp2Stream).destroy();
77+
if (body && typeof (body as ClientHttp2Stream).destroy === 'function') {
78+
(body as ClientHttp2Stream).destroy();
7979
} else if (body instanceof ReadableStream) {
8080
void body.cancel();
8181
}

0 commit comments

Comments
 (0)