From b9c297c61dc89ebda0480d053b0278d27e72b1b3 Mon Sep 17 00:00:00 2001 From: DevAI Sandbox Bot Date: Tue, 23 Sep 2025 12:28:30 +0000 Subject: [PATCH] possible fix for streaming --- src/rovo-dev/rovoDevChatProvider.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/rovo-dev/rovoDevChatProvider.ts b/src/rovo-dev/rovoDevChatProvider.ts index 33132bcb1..768741515 100644 --- a/src/rovo-dev/rovoDevChatProvider.ts +++ b/src/rovo-dev/rovoDevChatProvider.ts @@ -226,6 +226,12 @@ export class RovoDevChatProvider { let isFirstByte = true; let isFirstMessage = true; + // Queue posts to the webview to avoid backpressure blocking the stream reader + let postQueue: Promise = Promise.resolve(); + const enqueuePost = (p: Thenable) => { + postQueue = postQueue.then(() => p).catch(() => {}); + }; + while (true) { const { done, value } = await reader.read(); @@ -241,7 +247,7 @@ export class RovoDevChatProvider { } for (const msg of parser.flush()) { - await this.processRovoDevResponse(sourceApi, msg); + enqueuePost(this.processRovoDevResponse(sourceApi, msg)); } break; } @@ -253,9 +259,13 @@ export class RovoDevChatProvider { isFirstMessage = false; } - await this.processRovoDevResponse(sourceApi, msg); + // Do not await here; enqueue to prevent blocking the reader + enqueuePost(this.processRovoDevResponse(sourceApi, msg)); } } + + // Ensure all queued posts are delivered before returning + await postQueue; } private processRovoDevResponse(sourceApi: StreamingApi, response: RovoDevResponse): Thenable {