Repository navigation
Fix Auth token refresh slot cleanup race - #16765
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:
|
paulb777
left a comment
There was a problem hiding this comment.
Thanks, the actor-reentrancy analysis is right: the older call's defer can clear the newer call's slot, which costs at most one redundant token refresh. The generation check is a minimal, correct fix. One concern about the test inline.
|
Replaced the timing-dependent third caller with the suggested internal pendingTokenForTesting accessor. Immediately after the older task completes, the regression checks that the pending token is still token_v2; after the newer task completes, it checks that the slot is empty. The UUID generation implementation remains the minimal fix you confirmed correct; the Task equality alternative is optional. Compiled the actual coalescer and full test file in an isolated Linux Swift 6.1.3 package. The selected deterministic XCTest fails against the pre-PR coalescer (with only the same observation accessor added), seeing nil instead of token_v2; it passes against the updated coalescer. This is focused actual-source XCTest evidence, not a full FirebaseAuth/Apple build. Moved the changelog under Unreleased/#16765; pinned SwiftFormat 0.55.5 lint and git diff --check pass. Native Apple CI remains required. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request fixes an issue where an older token refresh completing could clear a newer in-flight token refresh due to actor reentrancy. It introduces a generation identifier to ensure only the matching task clears the pending slot, and adds corresponding unit tests. The review feedback suggests optimizing this mechanism by replacing the UUID generation with a simpler, more efficient monotonically increasing UInt64 counter to avoid unnecessary overhead.
|
The deterministic slot check now also passes in the actual FirebaseAuth Apple unit-test target. On Xcode 26.4.1/iOS simulator, all 6 |
|
Merged current upstream main normally in d15604c, resolving the CHANGELOG conflict by keeping both Unreleased entries. The token coalescer source and regression test files are unchanged from 2b2f9d5, which passed all six actual iOS TokenRefreshCoalescerTests in run37095537416/job111124572876. The previous native component evidence is reused; no claim of a post-merge native run. GitHub now reports this PR MERGEABLE. |
Summary
Validation
TokenRefreshCoalescerTestspass, includingtestOlderRefreshCompletionDoesNotClearNewerPendingRefresh. Native validation run checks out the exact PR source2b2f9d51e203ce54c6f55a42882bfdd4c9e5080a; its workflow is on a separate validation branch.