File tree Expand file tree Collapse file tree
packages/trigger-sdk/src/v3 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -451,9 +451,26 @@ export class SessionOutputChannel {
451451 const readableStreamSource = ensureReadableStream ( value ) ;
452452
453453 const abortController = new AbortController ( ) ;
454- const combinedSignal = options ?. signal
455- ? AbortSignal . any ?.( [ options . signal , abortController . signal ] ) ?? abortController . signal
456- : abortController . signal ;
454+ // `AbortSignal.any` lands in Node 20.3; the SDK still supports Node
455+ // 18.20+. On older runtimes fall back to wiring `options.signal` into
456+ // `abortController` manually so caller-driven cancellation propagates.
457+ let combinedSignal : AbortSignal = abortController . signal ;
458+ if ( options ?. signal ) {
459+ if ( typeof AbortSignal . any === "function" ) {
460+ combinedSignal = AbortSignal . any ( [ options . signal , abortController . signal ] ) ;
461+ } else {
462+ const callerSignal = options . signal ;
463+ if ( callerSignal . aborted ) {
464+ abortController . abort ( callerSignal . reason ) ;
465+ } else {
466+ callerSignal . addEventListener (
467+ "abort" ,
468+ ( ) => abortController . abort ( callerSignal . reason ) ,
469+ { once : true }
470+ ) ;
471+ }
472+ }
473+ }
457474
458475 // Resolve the init promise eagerly so we can capture which one this
459476 // writer uses for reactive invalidation below.
You can’t perform that action at this time.
0 commit comments