File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff 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 > {
You can’t perform that action at this time.
0 commit comments