Skip to content

Fix resumable downloads retrying a rejected range, progress on a resumed download without Content-Length, and empty local resources - #1026

Open
kean wants to merge 4 commits into
mainfrom
fix/data-loading-range-progress-empty
Open

kean wants to merge 4 commits into
mainfrom
fix/data-loading-range-progress-empty

Conversation

@kean

@kean kean commented Sep 26, 2026

Copy link
Copy Markdown
Owner
  • A resumed request the server rejected with "416 Range Not Satisfiable" sent the same Range again on every later attempt, so the image couldn't load until the entry left the resumable data storage. DataLoader rejects the response before the pipeline sees it, so urlResponse was nil, which looked like a request that ended before the server responded, and the rejected range was put back. The data is now dropped when the range was rejected.
  • The progress of a resumed download whose "206 Partial Content" has no Content-Length reported a total below the bytes already received (fraction == 1 from the first chunk). The total added the resumed bytes to -1; an unknown length is now reported as unknown, the way it is for a download that was never resumed.
  • An empty local file or an empty data: URL succeeded with zero bytes from data(for:), and image(for:) failed in the decoder. The local-resource fast path skipped the empty-data check the loader and data closure paths have; it now fails with .dataIsEmpty like them.

@kean
kean force-pushed the fix/data-loading-range-progress-empty branch from 782759b to bed3081 Compare September 26, 2026 20:40
@kean
kean force-pushed the fix/data-loading-range-progress-empty branch 2 times, most recently from 6dcb09f to b274a62 Compare November 1, 2026 15:50
kean added 4 commits November 2, 2026 19:19
The local-resource fast path sent whatever `Data(contentsOf:)` returned, so a
zero-length file or an empty `data:` URL succeeded with no data, and the
image request failed in the decoder instead.
…nown

The progress total added the resumed bytes to `-1`, which put it below the
bytes already received, so the task read as complete from its first chunk.
`DataLoader` rejects a "416 Range Not Satisfiable" before the pipeline sees
the response, which looked like a request that ended before the server
responded, so the rejected range was put back and sent again on every attempt.
@kean
kean force-pushed the fix/data-loading-range-progress-empty branch from b274a62 to 29071c1 Compare November 3, 2026 00:51
@kean kean added this to the 14.0.1 milestone Nov 8, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant