fix(sql_connect): e2e listen test refactor - #18496
Conversation
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 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 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. |
The e2e listen test for subscription cancels is failing. This PR refactors that test case.
Summary of Improvements Made by Antigravity
Eliminated Unhandled Exception Risks: Added completion checks (!listenerXReady.isCompleted, !listenerXReceivedUpdate.isCompleted) so multiple stream emissions will never throw StateError: Bad state: Future already completed.
Synchronized Readiness for Both Listeners: Used Future.wait([listener1Ready.future, listener2Ready.future]) to guarantee both subscriptions process initial setup before performing mutations.
Removed Arbitrary Future.delayed Sleep: Replaced the 5-second sleep with a deterministic Completer (listener2ReceivedUpdate.future) to prevent test flakiness and speed up execution.
Added Timeout Protection: Wrapped all awaited futures with .timeout(_listenTimeout) to prevent test hanging if a stream fails to emit.
Added Refetch Trigger for 2nd Movie: Added await MoviesConnector.instance.listMovies().ref().execute(); after creating Raiders of the Lost Arc to guarantee the query update is triggered for active stream subscribers.
Guaranteed Stream Cleanup: Placed resource cancellations inside a try ... finally block so both subscriptions are properly disposed of even if an assertion fails.