Skip to content

Commit b72a247

Browse files
committed
fix(core): notify stream completion on connection end, not only on consumer drain
1 parent b1c40b3 commit b72a247

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

packages/core/src/v3/apiClient/runStream.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,13 +515,15 @@ export class SSEStreamSubscription implements StreamSubscription {
515515

516516
if (done) {
517517
reader.releaseLock();
518+
this.notifyComplete();
518519
controller.close();
519520
return;
520521
}
521522

522523
if (this.options.signal?.aborted) {
523524
reader.cancel();
524525
reader.releaseLock();
526+
this.notifyComplete();
525527
controller.close();
526528
return;
527529
}
@@ -536,6 +538,7 @@ export class SSEStreamSubscription implements StreamSubscription {
536538
} catch (error) {
537539
if (this.options.signal?.aborted || this.cancelledByConsumer) {
538540
// User cancel — exit cleanly, don't retry.
541+
this.notifyComplete();
539542
controller.close();
540543
return;
541544
}
@@ -560,6 +563,7 @@ export class SSEStreamSubscription implements StreamSubscription {
560563
error?: Error
561564
): Promise<void> {
562565
if (this.options.signal?.aborted || this.cancelledByConsumer) {
566+
this.notifyComplete();
563567
controller.close();
564568
return;
565569
}

0 commit comments

Comments
 (0)