Skip to content

Commit a7ac708

Browse files
authored
make sure LM provider error bubble all the way, reject response streams and result promise (microsoft#205849)
fixes microsoft#205722
1 parent 076e9df commit a7ac708

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/vs/workbench/api/browser/mainThreadChatProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export class MainThreadChatProvider implements MainThreadChatProviderShape {
104104

105105
task.catch(err => {
106106
this._logService.error('[CHAT] extension request ERRORED', err, extension.value, requestId);
107+
throw err;
107108
}).finally(() => {
108109
this._logService.debug('[CHAT] extension request DONE', extension.value, requestId);
109110
});

src/vs/workbench/api/common/extHostChatProvider.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { Emitter, Event } from 'vs/base/common/event';
1717
import { ExtHostAuthentication } from 'vs/workbench/api/common/extHostAuthentication';
1818
import { localize } from 'vs/nls';
1919
import { INTERNAL_AUTH_PROVIDER_PREFIX } from 'vs/workbench/services/authentication/common/authentication';
20+
import { toErrorMessage } from 'vs/base/common/errorMessage';
2021

2122
type LanguageModelData = {
2223
readonly extension: ExtensionIdentifier;
@@ -54,18 +55,32 @@ class LanguageModelRequest {
5455
// responses: AsyncIterable<string>[] // FUTURE responses per N
5556
};
5657

57-
promise.finally(() => {
58-
this._isDone = true;
59-
if (this._responseStreams.size > 0) {
60-
for (const [, value] of this._responseStreams) {
61-
value.stream.resolve();
62-
}
63-
} else {
64-
this._defaultStream.resolve();
58+
promise.then(() => {
59+
for (const stream of this._streams()) {
60+
stream.resolve();
61+
}
62+
}).catch(err => {
63+
if (!(err instanceof Error)) {
64+
err = new Error(toErrorMessage(err), { cause: err });
65+
}
66+
for (const stream of this._streams()) {
67+
stream.reject(err);
6568
}
69+
}).finally(() => {
70+
this._isDone = true;
6671
});
6772
}
6873

74+
private * _streams() {
75+
if (this._responseStreams.size > 0) {
76+
for (const [, value] of this._responseStreams) {
77+
yield value.stream;
78+
}
79+
} else {
80+
yield this._defaultStream;
81+
}
82+
}
83+
6984
handleFragment(fragment: IChatResponseFragment): void {
7085
if (this._isDone) {
7186
return;

0 commit comments

Comments
 (0)