dataconnect(fix): Refresh expired Auth and App Check tokens in realtime query subscriptions#8346
Conversation
…me query subscriptions [no ci]
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. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where expired Auth and App Check tokens were not automatically refreshed upon server rejection. It introduces a ConnectionTokenManager to handle token lifecycle and updates DataConnectBidiConnectStream to support immediate retries on UNAUTHENTICATED errors. Additionally, several integration tests are updated and expanded to cover these scenarios. The reviewer feedback highlights three key improvements: marking shared mutable properties in ConnectionTokenManager as @Volatile to ensure thread safety, explicitly rethrowing CancellationException to prevent incorrect permanent failure states, and avoiding Duration.INFINITE in test timeouts to prevent CI/CD deadlocks.
…ally left behind from debugging
📝 PRs merging into main branchOur main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released. |
|
NOTE: The "Metalava SemVer Check" github actions failure is unrelated, and is fixed upstream by #8345 |
Fixes an issue in data connect where expired Firebase Auth and App Check tokens were not automatically refreshed and retried when rejected with an
UNAUTHENTICATEDerror by the server during realtime query subscriptions.Highlights
ConnectionTokenManagerto coordinate the retrieval, force-refreshing, and user-change validation of Auth and App Check tokens during bidirectional stream lifecycles.DataConnectBidiConnectStreamto accept a dynamicshouldRetrycallback, enabling seamless immediate retries upon token refreshes and proper permanent failures when credentials cannot be updated.CHANGELOG.md.Changelog
View Affected Files
executeandmutationRef) to simplify query/mutation execution in tests.shouldRetrycallback and a simplifiedRetryStrategyenum, removing custom exception wrappers.tokenflow.ConnectionTokenManagerto manage token lifecycles and provided the stream retry callback implementing the token refresh strategy.isPermanentlyFailedstream property.UNAUTHENTICATEDfrom generic retryable codes, reflecting its new specialized refresh logic.