feat(data-connect): add concrete WebSocketTransport#9736
feat(data-connect): add concrete WebSocketTransport#9736stephenarosaj merged 9 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 significantly enhances the Data Connect SDK by introducing a new streaming transport layer built upon WebSockets. This refactoring not only provides a concrete 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. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a concrete WebSocketTransport for the data-connect streaming layer, which is a significant feature. The implementation is well-structured, with good separation of concerns, lazy connection management, and de-duplication of connection attempts. The accompanying unit tests are comprehensive and cover the described behaviors well. I've identified one high-severity issue regarding a potential unhandled promise rejection that should be addressed.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a well-structured and robust WebSocketTransport implementation for DataConnect. The code effectively implements lazy connections, de-duplicates connection attempts, and includes thorough error handling. The addition of comprehensive unit tests and the refactoring of test utilities are also commendable. I have a couple of suggestions to further improve error reporting and the robustness of message parsing.
dconeybe
left a comment
There was a problem hiding this comment.
LGTM with only minor comments.
Description
✨ This PR introduces
WebSocketTransport, a concrete implementation of the streaming transport layer built on top of native WebSockets. This physical transport implements long-lived, full-duplex connections with the server, managing the low-level connection lifecycle separately from the higher-level streaming logic handled inAbstractDataConnectStreamTransport.Changes
WebSocketTransportclass to manage active connections.openConnection()prevents duplicate connection attempts by tracking pendingconnectionAttemptpromises and short-circuiting if there's already an active connection.handleWebSocketMessagestrictly parses the incomingDataConnectResponsewire protocol messages, ensuring optional arrays likeextensionscorrectly default to empty objects if omitted.closeConnection()andhandleWebsocketDisconnect()internally to safely and reliably ensureisReadyand internal states are cleared on unexpected server drops or client closures.Testing
Unit tests were added to
test/unit/websocketTransport.test.tsto cover all behavior:sendMessageuntil a successfulWebSocket.OPENis confirmed.openConnectionby verifying parallel or delayed executions silently adopt a single, shared pending promise.isReadygetter property remains precisely aligned with livereadyStateshifts at every physical connection phase.this.connectionandthis.connectionAttempt) upon explicit method invocation or externalsimulateClose()drops.resultorrequestIdare missing, and handles optional extensions properly.