File tree Expand file tree Collapse file tree 1 file changed +28
-23
lines changed
packages/core/src/v3/apiClient Expand file tree Collapse file tree 1 file changed +28
-23
lines changed Original file line number Diff line number Diff line change @@ -391,30 +391,35 @@ export class RunSubscription<TRunTypes extends AnyRunTypes> {
391
391
this . options . client ?. baseUrl
392
392
) ;
393
393
394
- const stream = await subscription . subscribe ( ) ;
395
-
396
- // Create the pipeline and start it
397
- stream
398
- . pipeThrough (
399
- new TransformStream ( {
400
- transform ( chunk , controller ) {
401
- controller . enqueue ( {
402
- type : streamKey ,
403
- chunk : chunk as TStreams [ typeof streamKey ] ,
404
- run,
405
- } as StreamPartResult < RunShape < TRunTypes > , TStreams > ) ;
406
- } ,
407
- } )
408
- )
409
- . pipeTo (
410
- new WritableStream ( {
411
- write ( chunk ) {
412
- controller . enqueue ( chunk ) ;
413
- } ,
414
- } )
415
- )
394
+ // Start stream processing in the background
395
+ subscription
396
+ . subscribe ( )
397
+ . then ( ( stream ) => {
398
+ stream
399
+ . pipeThrough (
400
+ new TransformStream ( {
401
+ transform ( chunk , controller ) {
402
+ controller . enqueue ( {
403
+ type : streamKey ,
404
+ chunk : chunk as TStreams [ typeof streamKey ] ,
405
+ run,
406
+ } ) ;
407
+ } ,
408
+ } )
409
+ )
410
+ . pipeTo (
411
+ new WritableStream ( {
412
+ write ( chunk ) {
413
+ controller . enqueue ( chunk ) ;
414
+ } ,
415
+ } )
416
+ )
417
+ . catch ( ( error ) => {
418
+ console . error ( `Error in stream ${ streamKey } :` , error ) ;
419
+ } ) ;
420
+ } )
416
421
. catch ( ( error ) => {
417
- console . error ( `Error in stream ${ streamKey } :` , error ) ;
422
+ console . error ( `Error subscribing to stream ${ streamKey } :` , error ) ;
418
423
} ) ;
419
424
}
420
425
}
You can’t perform that action at this time.
0 commit comments