Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Kharms opened this issue Aug 12, 2019 · 4 comments
Closed
Assignees
Labels
api: firestore Issues related to the Firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@Kharms
Copy link

Kharms commented Aug 12, 2019

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

@Kharms
Copy link
Author

Kharms commented Aug 12, 2019

Rolling back to 1.3.0 fixes the timeout issue, reintroduces: #7826

Might also be related to #8616

@tseaver tseaver added api: firestore Issues related to the Firestore API. type: question Request for information or clarification. Not an issue. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed type: question Request for information or clarification. Not an issue. labels Aug 12, 2019
@tseaver tseaver self-assigned this Aug 12, 2019
@tseaver
Copy link
Contributor

tseaver commented Aug 12, 2019

@Kharms Thanks for the report, and for investigating rolling back. As a workaround, I would recommend just avoiding the unsubscribe call

@jlara310
Copy link
Contributor

jlara310 commented Oct 3, 2019

busunkim96 pushed a commit to busunkim96/google-cloud-python that referenced this issue Oct 3, 2019
…s#9337)

Avoid blocking for ill-behaved daemon threads during BiDi shutdown.

Closes googleapis#8616, googleapis#9008.
@tseaver
Copy link
Contributor

tseaver commented Oct 4, 2019

Via #9337.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the Firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants