Skip to content

dataconnect(change): Exponential backoff in realtime query subscription reconnection now eagerly retries when network status changes#8446

Open
dconeybe wants to merge 6 commits into
mainfrom
dconeybe/dataconnect/ExponentialBackoffResetOnNetworkRestored
Open

dataconnect(change): Exponential backoff in realtime query subscription reconnection now eagerly retries when network status changes#8446
dconeybe wants to merge 6 commits into
mainfrom
dconeybe/dataconnect/ExponentialBackoffResetOnNetworkRestored

Conversation

@dconeybe

@dconeybe dconeybe commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

This PR integrates data connect's network status monitoring with the exponential backoff reconnection strategy for realtime query subscriptions. It ensures that when network connectivity is restored, the client immediately aborts any active retry delays and triggers a reconnection attempt using the initial backoff wait time.

This is a follow-up PR to #8421 that completes the network-status-triggered reconnection flow.

Highlights

  • Eager Reconnection on Network Restore: Realtime query subscriptions now listen to network restoration events to immediately reset the backoff logic and trigger an active retry.
  • Plumbed Network Connectivity Flow: Plumbed networkConnectivityRestoredFlow from FirebaseDataConnectFactory through FirebaseDataConnectImpl and DataConnectGrpcRPCs down to DataConnectBidiConnectStream.
  • Resets to Initial Backoff: Restored connectivity resets the backoff timer to its initial duration for subsequent failures.
  • Testing Infrastructure & Assertions: Added custom test helpers and comprehensive unit tests verifying immediate retries and backoff resets.
Changelog
  • CHANGELOG.md
  • DataConnectBidiConnectStream.kt
    • Added concurrent monitoring of networkConnectivityRestoredFlow to reset the retryBackoff and trigger an immediate reconnect upon network restoration.
  • DataConnectGrpcRPCs.kt
    • Updated constructor to accept and pass through networkConnectivityRestoredFlow.
  • FirebaseDataConnectFactory.kt
    • Instantiated and passed the networkConnectivityRestoredFlow down to the data connect implementation.
  • FirebaseDataConnectImpl.kt
    • Updated constructor to accept and pass through networkConnectivityRestoredFlow.
  • DataConnectBidiConnectStreamTesting.kt
    • Added testing helper signalOnRetryForTesting to intercept and signal backoff retry triggers during testing.
  • DataConnectGrpcRPCsUnitTest.kt
    • Updated test setup to pass empty flows for network monitoring.
  • FirebaseDataConnectImplUnitTest.kt
    • Updated test setup to pass empty flows for network monitoring.
  • QuerySubscriptionImplUnitTest.kt
    • Plumbed networkConnectivityRestoredFlow into the testing instance.
    • Added network connectivity restoration resets retries immediately unit test.
    • Added network connectivity restoration resets backoff delay to initial value unit test.
    • Extracted and updated the common backoff delay helper getExpectedBackoffWaitTimes.

@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.

@dconeybe

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces network connectivity monitoring to eagerly retry connections when network connectivity is restored, bypassing the full exponential backoff duration. It propagates a networkConnectivityRestoredFlow through the connection stream, gRPC RPCs, and factory classes, and adds corresponding unit tests. Feedback points out a potential issue in DataConnectBidiConnectStream where catching Throwable can swallow CancellationException and break structured concurrency; it is recommended to catch and rethrow CancellationException explicitly.

@github-actions

Copy link
Copy Markdown
Contributor

📝 PRs merging into main branch

Our 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.

@dconeybe
dconeybe marked this pull request as ready for review July 17, 2026 21:38
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.

1 participant