mirror of
https://github.com/Comfy-Org/comfy-swift-sdk.git
synced 2026-11-04 23:47:26 +00:00
[PR #2] [MERGED] fix(transport): treat POSIX socket-drop errors as transient so jobs recover via polling #7
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#7
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/2
Author: @mattmillerai
Created: 6/18/2026
Status: ✅ Merged
Merged: 6/18/2026
Merged by: @mattmillerai
Base:
main← Head:matt/be-1594-comfy-ios-backgrounding-a-running-job-shows-it-errored📝 Commits (1)
39c1eaefix(transport): treat POSIX socket-drop errors as transient so jobs recover via polling📊 Changes
2 files changed (+128 additions, -0 deletions)
View changed files
📝
Sources/ComfySwiftSDK/Internal/Transport.swift(+16 -0)➕
Tests/ComfySwiftSDKTests/TransportPOSIXTranslationTests.swift(+112 -0)📄 Description
ELI5
When the app is backgrounded mid-job, the OS kills the underlying WebSocket connection. On resume, the dropped-socket error was arriving as an
NSPOSIXErrorDomaincode (e.g.ENOTCONN,ECONNRESET) which fell throughTransport.translateto.unknown— a non-transient classification — soPollingFallback.isTransientreturnedfalseand the polling loop surfaced a false failure to the user. This change maps those OS-level socket-drop codes to.network(underlying:), whichisTransientalready recognises as transient, so the existing polling fallback takes over on resume and the job keeps going.What
In
Transport.translate(_:), added a POSIX branch between the existingURLErrorblock and the final.unknownfallback. The branch checksns.domain == NSPOSIXErrorDomainand mapsENOTCONN,ECONNRESET,ECONNABORTED,ENETDOWN,ENETUNREACH,ETIMEDOUT,EPIPE, andEHOSTUNREACHto.network(underlying: error).Why
URLSessiondoes not always wrap POSIX errors inURLError— it can surface them directly asNSErrorinNSPOSIXErrorDomain. The job itself is still running on the server; the error is purely a transport blip. Routing these codes through.network(already transient) is the correct classification: the polling fallback will back off, re-poll, and either resume from the last known state or deliver the completed output when the app comes back to the foreground.No
#if os(iOS)guards are needed; the POSIX constants (ENOTCONNetc.) are available on all Darwin platforms viaFoundation.Testing
swift build— clean, no warnings introduced.swift test— 108 tests, 0 failures. Includes 12 new tests inTransportPOSIXTranslationTests.swift:PollingFallback.isTransient(result) == true.URLError.cancelledstill maps to.cancelled(non-transient),URLError.notConnectedToInternetstill maps to.offline(transient),ComfyError.jobFailedstill passes through non-transient, and an unrelated POSIX code (EBADF) does not become transient.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.