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.
This PR is a follow-up to #368 and #371 that is more comprehensive. After digging in further with @jshier, I was able to create a set of stress tests to test all the odd edge cases including:
.resume()
on the request through the request receiptRequest
using theRequestReceipt
:receipt.request.cancel()
These tests were able to reproduce somewhat reliably race condition logic errors in the previous logic.
Goals ⚽
ImageDownloader
was relying on a task to be present when it can no longer be relied upon safely.ImageDownloader
would early out in completion if the response did not contain a request used to cache the image when successful.Implementation Details 🚧
These changes are simply removing the reliance on anything with request creation being synchronous. The stress tests were able to tease out the troublesome spots.
Testing Details 🔍
The big changes here are the stress tests. I've placed them directly in the test target for now since there are only 4 tests which hit the service 10 times each. Therefore, it's lightweight enough to not have to create a separate target.
These tests will break roughly 1 out of 4 tries when executing without the changes in the
ImageDownloader
. However, with these changes, I have yet to see any tests fail on AF beta 6 or 7.