Repository navigation
Fixed
- Session leak:
APIClientcreated a newURLSessionfor every request and never
invalidated it, so sessions and their delegates piled up for the life of the client.
All requests now share one long-lived session, which also brings back connection, TLS
and HTTP/2 reuse. Uploads with progress and Combine streams get a short-lived session
that is invalidated as soon as the task finishes. - Wrong request retried under concurrency: retries went through a queue shared by the
whole client and picked its last entry, so when two requests failed at once, one could
be retried with the other'sURLRequest. Each retry now uses only its own request. - async/await cancellation: cancelling the calling
Tasknow cancels the underlying
URLSessionTaskand any pending retry. Before, requests ran in a detached task and
kept going after cancellation. - Upload retries: a retried upload was sent as a plain data request with no body, and
transport errors and non-2xx responses on uploads were never retried. Retries now
rebuild the multipart body and go through the same policy as other requests. - Combine uploads and streams now cancel their
URLSessionTaskwhen the subscriber cancels. - A Combine stream now cancels its task when a line fails to decode, instead of leaving
it running after the publisher has failed. - iOS and tvOS builds: 2.2.2 did not compile for iOS or tvOS. The upload body writers
usedFileHandleAPIs that need 13.4 while the package targets 13.0; they now fall back
on older systems. APIClientno longer mutates theURLSessionConfigurationyou pass in.- The example app's local package path no longer depends on the name of the checkout folder.
Changed (breaking)
-
NetworkErrorhas a new case,.invalidRequest(Error). Endpoints whose
asURLRequest()throws (bad URL, encoding failure) now surface that error instead of
.unknown. Exhaustiveswitchstatements overNetworkErrorneed a new case. -
DefaultRetryHandlernow retries only transient failures of idempotent requests:- methods
GET,HEAD,PUT,DELETE,OPTIONSandTRACE - status codes 408, 429, 500, 502, 503 and 504
- transient
URLErrors
It uses exponential backoff with jitter (0.5s base, 30s cap). Before, it retried every
error, includingPOSTand 4xx responses, immediately. To restore the old timing pass
baseDelay: 0, and to opt methods back in useretryableMethods. - methods
-
RetryHandlerhas a new requirement,retryDelay(for:error:attempt:), with a default
implementation that returns0. -
updateDefaultCacheStrategy(_:)andupdateCacheConfiguration(_:)without
invalidation let in-flight requests finish, and apply to the next request.
Added
NetworkError.isCancellation.- Default implementations of
RetryHandler.shouldRetryAsyncand
modifyRequestForRetryAsyncthat call the synchronous versions, so custom handlers only
neednumberOfRetries,shouldRetryandmodifyRequestForRetry. DefaultRetryHandleroptions:retryableMethods,retryableStatusCodes,baseDelay,
maximumDelayandjitter.APIClienttests built on aURLProtocolstub. They cover session reuse, concurrent
retries, cancellation, upload retries and error mapping.- GitHub Actions CI: SwiftPM build and test on macOS, builds for iOS, tvOS and watchOS,
tests on the iOS Simulator, and an example app build. A manual release workflow tests
the chosen commit, then creates the tag and the GitHub release from this changelog.
Docs
- The README install line pointed at
from: "1.0.0", which resolves to the old
1.xSRNetworkManagerreleases. It now saysfrom: "3.0.0". - Removed the stale branch comparison table and the broken
.github/ABOUT.mdlink. - Documented the retry policy, backoff and session reuse.