Repository navigation
Prevent duplicate Storage requests on resume - #16771
dajiaohuang wants to merge 4 commits into
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
|
Thanks for the contribution! A few housekeeping items:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request prevents duplicate upload and download requests when resuming a task before its initial setup completes by introducing generation tracking (enqueueGeneration) in StorageDownloadTask and StorageUploadTask. Unit tests have been added to verify that earlier setups are discarded upon resumption. The review feedback highlights a potential data race in both task implementations where setupDiscardedHandlerForTesting is accessed outside of the lock, and suggests synchronizing this access by retrieving the handler under the lock before executing it.
paulb777
left a comment
There was a problem hiding this comment.
Thanks, this is easy to hit: putData(...) already enqueues, so an immediate resume() (or a quick pause()/resume()) runs setup twice and starts two fetchers, orphaning the first. The generation approach looks sound to me.
CI confirms one blocker: testUploadResumeDiscardsEarlierSetup crashes with Fatal error: Internal error enqueueing a Storage task in the SPM unit tests (e.g. spm (xcode-27, catalyst)). The cause is inline.
Coverage: please add tests for the most likely real-world trigger (putData(...).resume() and getData(...).resume() right after creation, with no pause()), and for download resume() during .progress.
|
Fixed the upload fixture to use child("object"), avoiding the nil metadata path. Both initial-setup and discard waits now use XCTest expectations with 10-second async fulfillment; teardown releases the service gate even after a timeout. Added immediate putData(...).resume() and getData(...).resume() variants without pause, plus a real download fetcher/progress-callback test that holds completion while exercising resume in a deterministic progress state and checks that only one request starts. The discard handler now has stateLock-protected storage; notification copies the handler under the lock and invokes it outside the lock. Both task types notify at all three setup-discard stages (before preparation, after service acquisition, and before fetcher installation). Moved the changelog under Unreleased/#16771. Four-file pinned SwiftFormat 0.55.5 lint and git diff --check pass. The new Apple/GTMSessionFetcher XCTest coverage has not run on this Windows host; current-head native CI remains required. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request prevents duplicate upload and download requests when resuming a task before its initial request setup has completed. It introduces an enqueueGeneration counter in both StorageDownloadTask and StorageUploadTask to track and discard obsolete setup tasks, and adds corresponding unit tests to verify this behavior. No review comments were provided, so there is no additional feedback.
|
The revised tests now run in the repository's actual Swift Package test target. At source 3b0555b, all five StorageTaskEnqueueTests passed with zero failures, including immediate upload/download resume and resume from the download progress callback: native XCTest results. These exercise the real GTMSessionFetcher callbacks with bounded waits and teardown gate release. |
Summary
Validation