Skip to content

Commit b9c297c

Browse files
author
DevAI Sandbox Bot
committed
possible fix for streaming
1 parent 723e216 commit b9c297c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/rovo-dev/rovoDevChatProvider.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ export class RovoDevChatProvider {
226226
let isFirstByte = true;
227227
let isFirstMessage = true;
228228

229+
// Queue posts to the webview to avoid backpressure blocking the stream reader
230+
let postQueue: Promise<any> = Promise.resolve();
231+
const enqueuePost = (p: Thenable<any>) => {
232+
postQueue = postQueue.then(() => p).catch(() => {});
233+
};
234+
229235
while (true) {
230236
const { done, value } = await reader.read();
231237

@@ -241,7 +247,7 @@ export class RovoDevChatProvider {
241247
}
242248

243249
for (const msg of parser.flush()) {
244-
await this.processRovoDevResponse(sourceApi, msg);
250+
enqueuePost(this.processRovoDevResponse(sourceApi, msg));
245251
}
246252
break;
247253
}
@@ -253,9 +259,13 @@ export class RovoDevChatProvider {
253259
isFirstMessage = false;
254260
}
255261

256-
await this.processRovoDevResponse(sourceApi, msg);
262+
// Do not await here; enqueue to prevent blocking the reader
263+
enqueuePost(this.processRovoDevResponse(sourceApi, msg));
257264
}
258265
}
266+
267+
// Ensure all queued posts are delivered before returning
268+
await postQueue;
259269
}
260270

261271
private processRovoDevResponse(sourceApi: StreamingApi, response: RovoDevResponse): Thenable<boolean> {

0 commit comments

Comments
 (0)