Skip to content

Fix Auth APNs token timeout for concurrent waiters - #16665

Open
Hokila wants to merge 2 commits into
firebase:mainfrom
Hokila:fix/auth-apns-timeout
Open

Hokila wants to merge 2 commits into
firebase:mainfrom
Hokila:fix/auth-apns-timeout

Conversation

@Hokila

@Hokila Hokila commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Motivation

AuthAPNSTokenManager starts one timeout for the first caller and coalesces later callers into the same pending batch. The timeout previously compared callback counts, so adding a second waiter changed the count and prevented the timeout from firing. The corresponding async getToken() continuations could then wait indefinitely.

Related: #13470

Changes

  • Track the active APNs registration batch with a request generation.
  • Complete every callback in the active batch when the shared timeout expires.
  • Ignore stale timeouts after cancellation or completion of an earlier batch.
  • Add callback-level, stale-timeout, and concurrent async waiter regression tests.
  • Document the fix in the FirebaseAuth changelog.

Non-goals

  • No changes to public APIs.
  • No changes to the separately identified FirebaseAuth error! sites or Storage/Database TODOs.

Validation

  • xcodebuild -scheme AuthUnit -destination 'platform=iOS Simulator,id=B33A771B-CD3A-41BA-81ED-2CFEE30AEA14' -only-testing:AuthUnit/AuthAPNSTokenManagerTests CODE_SIGNING_ALLOWED=NO test — 8 tests passed.
  • xcodebuild -scheme AuthUnit -destination 'platform=iOS Simulator,id=B33A771B-CD3A-41BA-81ED-2CFEE30AEA14' CODE_SIGNING_ALLOWED=NO test — 354 tests passed.
  • ./scripts/check.sh --allow-dirty --test-only upstream/main — passed.
  • git diff --check — passed.

API / release impact

Internal correctness fix only; no public API or compatibility changes.

@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

@paulb777 paulb777 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the PR!

@paulb777

Copy link
Copy Markdown
Member

Please fix the unit test build issue:

  - ERROR | [iOS] xcodebuild:  /Users/runner/work/firebase-ios-sdk/firebase-ios-sdk/FirebaseAuth/Tests/Unit/AuthAPNSTokenManagerTests.swift:234:46: error: implicit capture of 'self' requires that 'AuthAPNSTokenManagerTests' conforms to 'Sendable'

@paulb777
paulb777 self-requested a review September 17, 2026 13:32
@Hokila

Hokila commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in the latest commit and verified with CocoaPods lint on Xcode 26.4. Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants