Skip to content

feat(data-connect): TransportManager dynamic routing#9756

Merged
stephenarosaj merged 19 commits intopasta/mainfrom
pasta/penne
Mar 27, 2026
Merged

feat(data-connect): TransportManager dynamic routing#9756
stephenarosaj merged 19 commits intopasta/mainfrom
pasta/penne

Conversation

@stephenarosaj
Copy link
Copy Markdown
Contributor

Description

✨ This PR implement dynamic routing in TransportManager to decide between REST and Streaming transports based on connection readiness and active subscriptions.

Changes

  • Transport Manager Routing: Implemented executeShouldUseStream to route queries and mutations to the stream when available.
  • Lazy Loading: Configured TransportManager to instantiate the stream transport only upon the first subscription request.
  • REST Fallback: Operations automatically fall back to REST if the stream throws a fatal connection error.
  • Stream State Tracks: Added streamIsReady, isPendingClose, and hasActiveSubscriptions getters to AbstractDataConnectStreamTransport.

Testing

  • Unit Tests:
    • transportManager.test.ts covers routing decisions, lazy loading, and fallbacks.
    • streamTransport.test.ts verify logger is called on failed fire-and-forget unsubscriptions.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 25, 2026

⚠️ No Changeset found

Latest commit: e143303

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to the TransportManager by enabling dynamic routing between REST and streaming transports. This change improves efficiency by lazily initializing the streaming transport and enhances reliability through automatic fallback to REST when streaming connections encounter issues. The new routing logic ensures that the most appropriate transport is used based on the current state of the connection and active operations, providing a more robust and performant data connection experience.

Highlights

  • Transport Manager Dynamic Routing: Implemented dynamic routing in TransportManager to intelligently decide between REST and Streaming transports based on connection readiness and active subscriptions. The executeShouldUseStream method now routes queries and mutations to the stream when available.
  • Lazy Loading of Stream Transport: The TransportManager is configured to instantiate the stream transport only upon the first subscription request, optimizing resource usage.
  • REST Fallback Mechanism: Operations automatically fall back to the REST transport if the streaming transport encounters a fatal connection error, ensuring resilience.
  • Stream State Tracking: Added new getters (streamIsReady, isPendingClose, hasActiveSubscriptions, hasActiveExecuteRequests, isUnableToConnect) to AbstractDataConnectStreamTransport to track the state of the streaming connection.
  • Improved Error Logging: Updated error logging in stream-related components to use the logError utility instead of console.error for consistency and better error handling.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 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 counter productive. 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.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

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

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 streaming transport capabilities to the DataConnect client. The DataConnectTransportManager is updated to manage both REST and streaming transports, with invokeQuery and invokeMutation now preferring streaming with a fallback to REST if the stream is unable to connect. invokeSubscribe is updated to exclusively use the streaming transport. The changes also include refactoring isReady to streamIsReady in WebSocketTransport and integrating logError for error logging. A review comment suggests refactoring the duplicated logic in invokeQuery and invokeMutation into a shared helper method to improve maintainability.

Comment thread packages/data-connect/src/network/manager.ts
@stephenarosaj stephenarosaj marked this pull request as ready for review March 25, 2026 20:26
@stephenarosaj stephenarosaj requested review from a team and dconeybe as code owners March 25, 2026 20:26
@stephenarosaj stephenarosaj merged commit aa2c65a into pasta/main Mar 27, 2026
29 checks passed
@stephenarosaj stephenarosaj deleted the pasta/penne branch March 27, 2026 18:02
@firebase firebase locked and limited conversation to collaborators Apr 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants