Skip to content

Firestore transaction snapshot reads disconnect in-flight cancellation #15958

Closed

Description

@ReubenBond

Google.Cloud.Firestore 4.3.0's Transaction.GetSnapshotAsync(DocumentReference, CancellationToken) creates a linked CancellationTokenSource in a using block, then returns the asynchronous snapshot task. The linked source is disposed when the method returns, before the read completes, disconnecting later cancellation from the transaction and operation tokens.

Source: https://github.com/googleapis/google-cloud-dotnet/blob/Google.Cloud.Firestore-4.3.0/apis/Google.Cloud.Firestore/Google.Cloud.Firestore/Transaction.cs

The same pattern is present in the transaction's document-list, query, and aggregate-query snapshot methods, including on the current main branch.

To reproduce deterministically, use a fake FirestoreClient whose BeginTransactionAsync succeeds and whose BatchGetDocuments stream remains pending with a registration on CallSettings.CancellationToken. Begin a transaction with a caller cancellation token, start transaction.GetSnapshotAsync(document, callerToken), wait until the stream is pending, then cancel the caller token. The native read token remains uncanceled and the read stays pending. Passing the token to DocumentReference.GetSnapshotAsync directly cancels the pending stream.

Expected: cancellation during a pending transaction snapshot read reaches the native read. The linked token source should remain alive until the snapshot task completes, for example by awaiting the task inside its disposal scope.

Environment: .NET 10, Windows, Google.Cloud.Firestore 4.3.0.

Activity

  1. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    api: firestoreIssues related to the Firestore API.
    on Oct 7, 2026
  2. amanda-tarafa commented on Oct 7, 2026

    @amanda-tarafa
    Contributor

    Thanks for the report, we'll look into it as soon as we are able.

  3. robertvoinescu-work commented on Oct 7, 2026

    @robertvoinescu-work
    Contributor

    The fix has been merged #15963, and will go out in the next weeks regular release. I will close this issue for now and update here again once its released.

  4. robertvoinescu-work commented on Oct 20, 2026

    @robertvoinescu-work
    Contributor

    This has been released: #15970

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: firestoreIssues related to the Firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions