Skip to content

fix(firestore): always send the final loadBundle snapshot - #18813

Merged
Lyokone merged 1 commit into
mainfrom
fix/firestore-load-bundle-final-snapshot
Oct 20, 2026
Merged

Lyokone merged 1 commit into
mainfrom
fix/firestore-load-bundle-final-snapshot

Conversation

@Lyokone

@Lyokone Lyokone commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Description

LoadBundleTask.stream can hang forever on Android and Apple platforms because the final success snapshot is sometimes never sent.

The Dart stream only closes when it receives a snapshot with taskState == success. Natively, the plugin starts the load and then attaches a progress listener (Android addOnProgressListener, Apple addObserver). Neither SDK replays the current state to a listener added late: LoadBundleTask.setResult (Android) and LoadBundleTask::SetSuccess (Apple) only notify the listeners registered at that moment. If the bundle finishes loading before the listener is attached, success is never sent and await task.stream.last never completes. This is likely for small bundles or bundles already in the cache.

This is what keeps failing loadBundle(): LoadBundleTaskProgress stream snapshots on the Android e2e job: it runs into the 5 minute test timeout on main and on unrelated PRs. #18522 already bounded the fixture download, so the remaining hang is the stream itself.

The final snapshot now comes from a callback registered with the task itself, which also runs when the task has already completed:

  • Android: addOnSuccessListener sends the final snapshot. The progress listener only forwards non-success snapshots, so success is sent once.
  • iOS/macOS: the loadBundle:completion: handler, which the SDK registers when the task is created, sends the final snapshot as well as errors. The observer only forwards in-progress snapshots.

Windows is not affected: its progress callback is passed to LoadBundle when the load starts.

Testing

On an Android emulator (API 36) against the Firestore emulator, I ran a local stress loop that reloads an already-cached bundle and waits up to 5 s for task.stream.last each time:

Android handler Injected 100 ms delay before attaching listeners Loads that never completed
Before no 0 / 300 (the race window is too small to hit on a fast machine)
Before yes 39 / 40
After yes 0 / 40
After no 0 / 300

With the fix, the loadBundle() and namedQuery*() e2e tests pass on Android. I haven't run iOS/macOS locally, so the e2e jobs here cover them. The no-replay behavior is the same in the Apple SDK (LoadBundleTask::Observe / SetSuccess).

Related Issues

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

The plugin started loading the bundle and only then attached its progress
listener (Android) or observer (Apple). Neither SDK replays the current state
to a listener added later, so when the bundle finished loading first, the
success snapshot was never sent and LoadBundleTask.stream never closed.

Send the final snapshot from a callback registered with the task itself,
which also runs for a task that has already completed: addOnSuccessListener
on Android, and the loadBundle:completion: handler on iOS and macOS. Progress
listeners now only forward in-progress snapshots, so success is sent once.
@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

@Lyokone
Lyokone merged commit 31dd9ba into main Oct 20, 2026
44 checks passed
@Lyokone
Lyokone deleted the fix/firestore-load-bundle-final-snapshot branch October 20, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants