File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -270,18 +270,25 @@ export function Chat() {
270
270
// Handle error messages
271
271
try {
272
272
const errorData = JSON . parse ( line . slice ( 2 ) )
273
- pendingStreamEventsRef . current . push ( {
274
- type : 'error' ,
275
- message :
276
- errorData . message || 'An error occurred during streaming' ,
277
- details : errorData . details ,
278
- } )
273
+ // Process error events immediately instead of buffering
274
+ setStreamBuffer ( ( prev ) => [
275
+ ...prev ,
276
+ {
277
+ type : 'error' ,
278
+ message :
279
+ errorData . message || 'An error occurred during streaming' ,
280
+ details : errorData . details ,
281
+ } ,
282
+ ] )
279
283
} catch ( e ) {
280
284
console . error ( 'Failed to parse error data:' , e )
281
- pendingStreamEventsRef . current . push ( {
282
- type : 'error' ,
283
- message : 'An unknown error occurred during streaming' ,
284
- } )
285
+ setStreamBuffer ( ( prev ) => [
286
+ ...prev ,
287
+ {
288
+ type : 'error' ,
289
+ message : 'An unknown error occurred during streaming' ,
290
+ } ,
291
+ ] )
285
292
}
286
293
return
287
294
}
You can’t perform that action at this time.
0 commit comments