Repository navigation
Cancel the orphaned progressive operation when a dependency fails - #898
Merged
Merged
Conversation
Without the guard, a response that doesn't need decompression still reached `storeImageInCaches`, letting a stale progressive result write to the memory cache after the task had already ended.
A pending progressive decode/process/decompress is cancelled when the final value arrives, but the errors bypass those call sites: they are forwarded generically, so the operation was left in the queue holding on to the decoded preview until the queue drained past it.
kean
force-pushed
the
fix/async-task-cancel-operation-on-error
branch
from
August 15, 2026 16:44
96d7dbe to
2591f4b
Compare
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.
A pending progressive decode, processing, or decompression operation is cancelled when the final value arrives —
TaskFetchOriginalImage.didReceiveData,TaskLoadImage.process, andTaskLoadImage.didReceiveImageResponseall do it explicitly. The errors bypass those call sites entirely: they are forwarded generically byAsyncTask.Publisher.subscribe(_:onValue:), so a task that failed left its operation in the queue, holding on to the decoded preview and the captured decoder until the queue drained past it.The cancellation now happens in that forwarder. It deliberately isn't in
AsyncTask.terminate:operationis either the work a task awaits (decoding, processing — cleared before the result is delivered) or the operation that runs the task itself (TaskFetchOriginalData.loadData,loadAsyncData,TaskFetchOriginalImage.loadAsyncImage— never cleared). For the latter, the terminal event is reported from inside the operation, and sincesendterminates before delivering the event, a blanket cancel would run the whole downstream delivery chain inside a just-cancelledTask.TaskLoadImage.didReceiveImageResponsealso checksisDisposedbefore the no-decompression early return, so a late response can't reachstoreImageInCachesand write a stale preview to the memory cache after the task has ended.