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. |
SelaseKay
left a comment
There was a problem hiding this comment.
Hi @chiliec, thanks for the PR.
Two tests worth adding, neither blocks this:
- Re-listen while the first pigeon call is still pending.
listen, cancel,listenagain, complete the first observer id, then a second id. Only the second channel should receivelisten. - A cancel-path test for
snapshotsInSync(). The generation check returns beforereceiveGuardedBroadcastStream, so that test does not have to encode thefirestoreargument.
The pigeon call still registers a native stream handler before it returns. An early return never callsonCancelon that handler, so it stays in the plugin map until the engine detaches.addSnapshotListeneris not called, so there is no watch target. A normal listen/cancel already leaves that map entry behind.
LGTM.
|
Thanks for the review, @SelaseKay! I've added both tests you requested to
All tests pass headless via |
|
Hi @chiliec, CI is failing. Kindly run |
|
Thanks @SelaseKay — done. Ran |
Description
Fixes #18724.
snapshots()onMethodChannelDocumentReference/MethodChannelQueryandMethodChannelFirebaseFirestore.snapshotsInSync()await the pigeon registration call insideonListen, and only then subscribe to the event channel. If the subscription is cancelled during that await,onCancelsees a nullsnapshotStreamSubscriptionand does nothing, andonListenstill subscribes when the call returns. The native listener then attaches and is never removed.This adds a listen generation counter to each of the three:
onCancelbumps it, andonListenreturns without subscribing to the event channel if the generation changed during the await. A counter is used instead of a bool so the broadcast controller being re-listened while the first await is still pending is also handled.onCancelalso clears the stored subscription.Tests
New group in
test/method_channel_firestore_test.dart. The pigeon mock holdsdocumentReferenceSnapshot/querySnapshoton a completer, the test doeslisten().cancel(), completes the observer id, and asserts that nothing was sent on the event channel:DocumentReference.snapshots()andQuery.snapshots(): fail onmain(Actual: ['listen']), pass with this change.listenand thencancel.snapshotsInSync()gets the same fix but has no test. Its event channel passes a non-codec-encodablefirestoreargument, and that breaks the mock messenger.(
timestamp_test.dart"dates before 1970" also fails on unmodifiedmainwhen the local timezone is non-UTC, so I ran the full suite withTZ=UTC.)I did not run this on an Android or iOS device. The fix only touches the Dart method-channel layer.