mirror of
https://github.com/Comfy-Org/comfy-swift-sdk.git
synced 2026-11-04 23:47:26 +00:00
[PR #27] [MERGED] refactor(transport): share best-effort cancelJob-on-cancelled tail between WS and polling producers #29
Labels
No labels
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-swift-sdk#29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/comfy-swift-sdk/pull/27
Author: @mattmillerai
Created: 7/4/2026
Status: ✅ Merged
Merged: 7/5/2026
Merged by: @mattmillerai
Base:
main← Head:matt/be-2356-share-cancel-on-cancelled📝 Commits (1)
e235281refactor(transport): share best-effort cancelJob-on-cancelled tail between WS and polling producers📊 Changes
2 files changed (+20 additions, -10 deletions)
View changed files
📝
Sources/ComfySwiftSDK/Internal/PollingFallback.swift(+19 -5)📝
Sources/ComfySwiftSDK/Internal/WebSocketSession.swift(+1 -5)📄 Description
ELI-5
When you cancel a job stream from your side, the SDK also tells the server to cancel the job — a nice "cancel means cancel everywhere" guarantee. Two different stream producers (the WebSocket path and the polling-fallback path) had the exact same little block of code doing this, copy-pasted. This moves that block into one shared helper both call, so there's a single place for that behavior instead of two identical copies.
What changed
The WebSocket and polling stream producers each carried an identical
onTerminationsnippet:Extracted verbatim into one shared static helper:
WebSocketSession.eventStreamnow callsPollingFallback.fireCancelJobIfCancelled(...).PollingFallback.eventStreamnow callsSelf.fireCancelJobIfCancelled(...).PollingFallback, the existing home for statics already shared across the stream producers (e.g.isTransient).Scope / judgment calls
ReattachCoordinatoris intentionally left untouched. ItsonTerminationis just{ _ in task.cancel() }— reattaching to an already-running job must not fire a server-side cancel, so it deliberately never had this snippet and still doesn't.cancelJobside-effect is shared. The surroundingAsyncThrowingStreamscaffold is genuinely different across producers (WS registers into aWebSocketStreamRegistryand wraps awithTaskCancellationHandlerwith a WS-closeonCancel; polling does not), so it is not genericized here — that would be premature abstraction.Testing
swift build— clean.swift test— all 150 tests across 20 suites pass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.