Skip to content

Commit 8e44d0a

Browse files
Fix: Only cancel when cancelled
1 parent 6a13624 commit 8e44d0a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Sources/GraphQL/Subscription/EventStream.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ extension AsyncThrowingStream {
4343
}
4444
}
4545

46-
continuation.onTermination = { @Sendable _ in
47-
task.cancel()
46+
continuation.onTermination = { @Sendable reason in
47+
if case .cancelled = reason {
48+
task.cancel()
49+
}
4850
}
4951
}
5052
}
@@ -64,8 +66,10 @@ extension AsyncThrowingStream {
6466
}
6567
}
6668

67-
continuation.onTermination = { @Sendable _ in
68-
task.cancel()
69+
continuation.onTermination = { @Sendable reason in
70+
if case .cancelled = reason {
71+
task.cancel()
72+
}
6973
}
7074
}
7175
}

0 commit comments

Comments
 (0)