Skip to content

feat(data-connect): Integrate Query Layer with Streaming#9793

Merged
stephenarosaj merged 40 commits intopasta/mainfrom
pasta/ziti
Apr 1, 2026
Merged

feat(data-connect): Integrate Query Layer with Streaming#9793
stephenarosaj merged 40 commits intopasta/mainfrom
pasta/ziti

Conversation

@stephenarosaj
Copy link
Copy Markdown
Contributor

@stephenarosaj stephenarosaj commented Mar 30, 2026

Description

✨ This PR integrates QueryManager with the streaming transport to support query subscriptions and handle stream notifications, and allow for executions over the stream.

Changes

  • Query Manager: Added invokeSubscribe and invokeUnsubscribe calls, and pass notification hook to the Transport layer which handles updating cache and notifying subscribers in data and error return cases.
  • Url Builders: Converted default REST URL builder into standalone function for REST endpoints, and created a new one for WebSockets.
  • send*Message Functions: Refactor send*Message() functions to more clearly orchestrate order of operations and eliminate race conditions - ensure connection, then prepare message, then send.

Other Changes:

  • WebSocket: Updated close codes to GRACEFUL_CLOSE to avoid Node environment errors.
  • Update some tests, refactoring some and stubbing transport invokeSubscribe() methods in others (since subscribe() now has increased functionality and invokes network operations), as well as adding in new required members after refactoring.
  • Added some new documentation to fields / functions.

Testing

  • Initialization: subscribe starts the stream; execution operations do not.
  • Routing: executeQuery and executeMutation use the stream when active.
  • Lifecycle: unsubscribe only calls the transport on the last subscriber (reference counting).
  • Notifications: Pushed data updates the query cache and notifies all subscribers; pushed errors are routed to all subscribers.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 30, 2026

⚠️ No Changeset found

Latest commit: 8d3c2c5

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

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 integrates streaming capabilities into the DataConnect query layer, enabling data updates through a subscription model. Key changes include the implementation of subscription lifecycle management in QueryManager, the addition of a notification hook to handle incoming transport data and update the cache, and adjustments to WebSocket close codes for Node.js compatibility. Review feedback highlights a potential race condition where subscriptions might miss immediate notifications, an issue with JSON.stringify omitting non-enumerable Error properties, and a suggestion to use custom WebSocket close codes (3000-4999) for better failure diagnostics.

Comment thread packages/data-connect/src/core/query/QueryManager.ts
Comment thread packages/data-connect/src/core/query/QueryManager.ts
Comment thread packages/data-connect/src/network/stream/websocket.ts
@stephenarosaj stephenarosaj marked this pull request as ready for review March 30, 2026 22:53
@stephenarosaj stephenarosaj requested review from a team and dconeybe as code owners March 30, 2026 22:53
@stephenarosaj
Copy link
Copy Markdown
Contributor Author

/gemini review

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 integrates streaming capabilities into the DataConnect query layer, enabling data updates through subscriptions. Key changes include updating QueryManager to manage transport-level subscriptions, introducing specialized URL builders for REST and WebSocket endpoints, and refining WebSocket closure logic for better environment compatibility. Feedback highlights opportunities to refactor duplicated key generation logic, remove redundant cache updates, and ensure that error stringification and WebSocket close reasons adhere to technical constraints.

Comment thread packages/data-connect/src/core/query/QueryManager.ts
Comment thread packages/data-connect/src/core/query/QueryManager.ts
Comment thread packages/data-connect/src/core/query/QueryManager.ts
Comment thread packages/data-connect/src/network/stream/websocket.ts
@stephenarosaj stephenarosaj merged commit c29b94b into pasta/main Apr 1, 2026
29 checks passed
@stephenarosaj stephenarosaj deleted the pasta/ziti branch April 1, 2026 21:40
@firebase firebase locked and limited conversation to collaborators May 2, 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