Skip to content

chore(firestore): spec test that reproduces the race condition leading to ca9 pendingResponses < 0#9841

Draft
MarkDuckworth wants to merge 1 commit intomainfrom
markduckworth/ca9-spec-repro
Draft

chore(firestore): spec test that reproduces the race condition leading to ca9 pendingResponses < 0#9841
MarkDuckworth wants to merge 1 commit intomainfrom
markduckworth/ca9-spec-repro

Conversation

@MarkDuckworth
Copy link
Copy Markdown
Contributor

To run this test:

npx ts-node ./scripts/run-tests.ts --main=test/register.ts --emulator 'test/unit/specs/remote_store_spec.test.ts'

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 14, 2026

⚠️ No Changeset found

Latest commit: 9e4fc11

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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 introduces the allowUnlistedTargetRemoval configuration to the Firestore spec test framework, enabling tests to handle server-side removals of targets not currently tracked by the client. It includes a new test case for target removal after a re-listen. Feedback focuses on a logic error in spec_builder.ts where the flag incorrectly prevents the removal of active targets from the expected state, and suggests removing unnecessary any type casts now that the property is part of the SpecConfig interface.

Comment on lines +794 to +796
if (!(this.config as any).allowUnlistedTargetRemoval) {
delete this.activeTargets[this.getTargetId(query)];
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This conditional logic appears to be incorrect. If the server sends a watchRemove with a cause (error), the target should be removed from the expected activeTargets regardless of the allowUnlistedTargetRemoval setting. The flag is intended to allow the server to remove targets that the client doesn't currently track as active (suppressing the assertion in the test runner), but if the target is active, it should still be removed from the expectations when a remove event is received. Additionally, the any cast is unnecessary.

      delete this.activeTargets[this.getTargetId(query)];

!this.currentStep,
'allowUnlistedTargetRemoval() must be called before all spec steps.'
);
(this.config as any).allowUnlistedTargetRemoval = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The cast to any is unnecessary here because allowUnlistedTargetRemoval has been added to the SpecConfig interface in spec_test_runner.ts.

Suggested change
(this.config as any).allowUnlistedTargetRemoval = true;
this.config.allowUnlistedTargetRemoval = true;

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.

1 participant