Repository navigation
[swift6][urlsession] Deliver successful responses on apiResponseQueue - #25205
Merged
4brunu merged 1 commit intoOct 9, 2026
Merged
Conversation
The urlsession request builder delivered failures on apiResponseQueue (main by default) but called the completion of successful responses directly on URLSession's delegate queue. Callers relying on main-queue delivery, such as @mainactor Combine sinks, then ran off the main thread; under Swift 6 that trips the runtime isolation check and crashes the combineLibrary sample tests. Deliver the result of processRequestResponse on apiResponseQueue too; decoding stays on URLSession's queue. Update swift6 samples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #25204.
The urlsession request builder delivered failures on
apiResponseQueue(the main queue by default), but called the completion of successful responses directly on URLSession's delegate queue. This change sends the result ofprocessRequestResponsethroughapiResponseQueueas well, so every result arrives where callers expect it. Decoding still happens on URLSession's queue; only the delivery moves. The retry and failure paths already dispatched toapiResponseQueue, so nothing is dispatched twice.This also fixes the next sample-test failure on Bitrise after #25203: the combineLibrary test class is
@MainActor, so its Combinesinkclosures crashed under Swift 6's runtime isolation check when a successful response arrived off the main thread.Verified with the generated combineLibrary client against https://petstore.swagger.io: before, a successful
addPetandgetPetByIdcompleted off the main thread and a 404 on it, and a@MainActorsinkloggeddata race detected: @MainActor function ... was not called on the main thread. After, all three complete on the main thread and thesinkruns without the warning. The default, urlsessionLibrary and combineLibrary samples build.PR checklist
Summary by cubic
Fixes #25204 by delivering successful URLSession responses on
apiResponseQueue, matching the failure path. Previously failures were dispatched toapiResponseQueuewhile successful responses completed directly on URLSession's delegate queue, which made@MainActorCombine sinks run off the main thread and trip Swift 6's runtime isolation check. Decoding still happens on URLSession's queue; only delivery moves. The retry and failure paths already dispatched toapiResponseQueue, so nothing is dispatched twice. This also fixes the combineLibrary sample-test failure on Bitrise.Written for commit 28757a5. Summary will update on new commits.