Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Firestore: watch.unsubscribe() causes Google Cloud Function to timeout. #9008

Closed
@Kharms

Description

@Kharms

Environment details

Environment: GCF python37 runtime
Version: google-cloud-firestore==1.4.0

Steps to reproduce

  1. Initialize a fs document:
  2. Deploy a HTTP triggered GCF that creates a listener, then unsubscribes.
  3. View logs.

Code example

from google.cloud import firestore


# Initialization code, run prior to deploy.
# fs_client = firestore.Client()
# doc_ref = fs_client.collection("test").document("subtest")
# doc_ref.set({"hello": "world"})


def abort_now_listener(doc_snapshot, changes, read_time):
    for doc in doc_snapshot:
        doc_vals = doc.to_dict()
        print(doc_vals["hello"])


# gcloud functions deploy watch_fs --runtime python37 --trigger-http
def watch_fs(request):
    print("creating client")
    fs_client = firestore.Client()
    doc_ref = fs_client.collection("test").document("subtest")
    print(doc_ref)
    watcher = doc_ref.on_snapshot(abort_now_listener)
    print("after watcher")
    watcher.unsubscribe()
    print("the end!")
    return "hello world"

GCF Logs attached.

Screen Shot 2019-08-12 at 11 06 14 AM

Metadata

Metadata

Assignees

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