feat(data-connect): Add baseline streaming functionality (sending, tracking, routing requests)#9718
feat(data-connect): Add baseline streaming functionality (sending, tracking, routing requests)#9718stephenarosaj merged 25 commits intopasta/mainfrom
Conversation
|
Summary of ChangesHello, 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 lays the foundational framework for streaming transport within the Data Connect client. It introduces the necessary mechanisms to initiate, track, and manage the lifecycle of streaming requests (queries, mutations, and subscriptions) and to correctly route their corresponding responses. By centralizing resource path definitions and implementing robust request/response handling, this change provides a solid, test-covered baseline for future streaming capabilities without including specific optimizations. Highlights
🧠 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. Changelog
Activity
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 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 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces the foundational components for streaming transport, including request tracking and response routing. The changes are well-structured, moving common logic to base classes and adding comprehensive unit tests for the new functionality. I have a few suggestions to improve error handling in the response routing logic and to make the new tests more robust against unhandled promise rejections.
| const { resolve } = this._executeRequestPromises.get(requestId)!; | ||
| resolve(response); | ||
| this._executeRequestPromises.delete(requestId); |
There was a problem hiding this comment.
The reject function for the promise is not being used in _handleMessage. If a response for an execute request contains errors, the corresponding promise should be rejected rather than resolved. This provides a more idiomatic error handling mechanism for consumers of invokeQuery and invokeMutation.
| const { resolve } = this._executeRequestPromises.get(requestId)!; | |
| resolve(response); | |
| this._executeRequestPromises.delete(requestId); | |
| const { resolve, reject } = this._executeRequestPromises.get(requestId)!; | |
| if (response.errors?.length) { | |
| reject(response.errors); | |
| } else { | |
| resolve(response); | |
| } | |
| this._executeRequestPromises.delete(requestId); |
There was a problem hiding this comment.
In RESTTransport, errors are thrown by dcFetch when there's a fetch request error or when there's errors in the response - this happens when the response initially comes in, not in the invoke* functions. We should use the same error system for streaming.
Description
✨ This PR establishes the baseline streaming transport functionality - making and tracking requests, and routing responses to requests. It does not include optimizations, and has only unit tests for request tracking/routing logic (since there is no concrete streaming transport implementation yet).
Changes
AbstractDataConnectStreamTransportand implementedinvoke*methods to send and manage logical stream requests.handleMessageto focus on routing response data to tracked promises or subscription notification hooks based on incoming server request IDs. Throws explicit unhandled requestId errors.Testing
New unit tests were added in
test/unit/streamTransport.test.tsto test the request management:x-firebase-gmpidheader is included in messages (should have been in last PR).invoke*methods are called.