Skip to content

fix(firestore): improved robustness and logging in query listen stream creation and re-creation#9985

Merged
MarkDuckworth merged 8 commits into
mainfrom
markduckworth/fix-ca9
May 22, 2026
Merged

fix(firestore): improved robustness and logging in query listen stream creation and re-creation#9985
MarkDuckworth merged 8 commits into
mainfrom
markduckworth/fix-ca9

Conversation

@MarkDuckworth
Copy link
Copy Markdown
Contributor

@MarkDuckworth MarkDuckworth commented May 19, 2026

This pull request refactors the WatchChangeAggregator to handle TargetState more explicitly by removing the ensureTargetState method and requiring manual state management. The changes ensure that unknown or inactive targets are skipped safely across various event handlers. Debug logging was added to add visibility into any skipped targets. Additionally, new spec tests were added to cover stale acknowledgment scenarios.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

🦋 Changeset detected

Latest commit: 2661d1c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/firestore Patch
firebase Patch
@firebase/firestore-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the WatchChangeAggregator to handle TargetState more explicitly by removing the ensureTargetState method and requiring manual state management, which is supported by a new _targetStates getter and an ensureTargetData helper for test utilities. The changes ensure that unknown or inactive targets are skipped safely across various event handlers. Additionally, new spec tests were added to cover stale acknowledgment scenarios. The reviewer provided feedback suggesting the removal of redundant null checks in handleDocumentChange and handleTargetChange where the target state existence is already guaranteed.

Comment thread packages/firestore/src/remote/watch_change.ts Outdated
Comment thread packages/firestore/src/remote/watch_change.ts
@MarkDuckworth MarkDuckworth changed the title WIP pending reponses on stream reset fix(firestore): improved robustness and logging in query listen stream creation and re-creation May 20, 2026
@MarkDuckworth
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves the robustness and logging of query listen streams by refining how target states are tracked and handled within the WatchChangeAggregator. Key changes include exporting TargetState for better logging and testing, preventing the processing of unknown target IDs, and adding several spec tests to cover edge cases like stale ACKs and stream closures. Feedback from the review highlights opportunities to optimize performance by eliminating redundant map lookups and consolidating logic checks where targetState is already available in the local scope.

Comment thread packages/firestore/src/remote/watch_change.ts
Comment thread packages/firestore/src/remote/watch_change.ts
Comment thread packages/firestore/src/remote/watch_change.ts
@MarkDuckworth MarkDuckworth marked this pull request as ready for review May 20, 2026 20:53
@MarkDuckworth MarkDuckworth requested review from a team as code owners May 20, 2026 20:53
Copy link
Copy Markdown
Contributor

@wu-hui wu-hui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good to me, I have a minor question about spec tests setup.

Comment thread packages/firestore/test/util/helpers.ts Outdated
@wu-hui wu-hui assigned MarkDuckworth and unassigned wu-hui May 21, 2026
@MarkDuckworth MarkDuckworth merged commit 85f6f4e into main May 22, 2026
75 of 81 checks passed
@MarkDuckworth MarkDuckworth deleted the markduckworth/fix-ca9 branch May 22, 2026 16:37
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.

2 participants