This repository was archived by the owner on Aug 30, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 30, 2026. It is now read-only.
AttributeError: '_UnaryStreamMultiCallable' object has no attribute '_retry' #596
Copy link
Copy link
Closed
Labels
🚨This issue needs some love.This issue needs some love.api: firestoreIssues related to the googleapis/python-firestore API.Issues related to the googleapis/python-firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.triage meI really want to be triaged.I really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- OS type and version: MacOS 12.3.1
- Python version:
python --versionPython 3.8.13 - pip version:
pip --versionpip 21.3.1 google-cloud-firestoreversion:pip show google-cloud-firestoreVersion: 2.3.4
Steps to reproduce
firebase_admin.initialize_app()[print(e) for e in firestore.client().collection("foos").stream()]
Stack trace
Traceback (most recent call last):
File "/Users/louisbeaumont/Documents/inkdropy/env/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 97, in __next__
return next(self._wrapped)
File "/Users/louisbeaumont/Documents/inkdropy/env/lib/python3.8/site-packages/grpc/_channel.py", line 426, in __next__
return self._next()
File "/Users/louisbeaumont/Documents/inkdropy/env/lib/python3.8/site-packages/grpc/_channel.py", line 809, in _next
raise self
grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
status = StatusCode.INTERNAL
details = "Received RST_STREAM with error code 2"
debug_error_string = "{"created":"@1654001431.880353000","description":"Error received from peer ipv6:[2a00:1450:4007:80f::200a]:443","file":"src/core/lib/surface/call.cc","file_line":1070,"grpc_message":"Received RST_STREAM with error code 2","grpc_status":13}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/louisbeaumont/Documents/inkdropy/env/lib/python3.8/site-packages/google/cloud/firestore_v1/query.py", line 279, in stream
response = next(response_iterator, None)
File "/Users/louisbeaumont/Documents/inkdropy/env/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 100, in __next__
raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.InternalServerError: 500 Received RST_STREAM with error code 2
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "scripts/hack.py", line 638, in <module>
fire.Fire(
File "/Users/louisbeaumont/Documents/inkdropy/env/lib/python3.8/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/Users/louisbeaumont/Documents/inkdropy/env/lib/python3.8/site-packages/fire/core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/Users/louisbeaumont/Documents/inkdropy/env/lib/python3.8/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "scripts/hack.py", line 480, in hack
for doc in tqdm(fc.collection("products").stream()):
File "/Users/louisbeaumont/Documents/inkdropy/env/lib/python3.8/site-packages/tqdm/std.py", line 1180, in __iter__
for obj in iterable:
File "/Users/louisbeaumont/Documents/inkdropy/env/lib/python3.8/site-packages/google/cloud/firestore_v1/query.py", line 281, in stream
if self._retry_query_after_exception(exc, retry, transaction):
File "/Users/louisbeaumont/Documents/inkdropy/env/lib/python3.8/site-packages/google/cloud/firestore_v1/query.py", line 230, in _retry_query_after_exception
retry = gapic_callable._retry
AttributeError: '_UnaryStreamMultiCallable' object has no attribute '_retry'
Sometimes it happens, sometimes it does not... I know it's not the best issue description, I never had issue with stream() before.
In my for ...stream() I run a bunch of set / delete in batch queries, can it be related (yes I ensure max batch size 500)? Am I hitting the limits of Firestore?
Can you delete documents while using stream()?
Or is stream() kind of in conflict with batch writes?
Read operations must come before write operations
https://firebase.google.com/docs/firestore/manage-data/transactions
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
🚨This issue needs some love.This issue needs some love.api: firestoreIssues related to the googleapis/python-firestore API.Issues related to the googleapis/python-firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.triage meI really want to be triaged.I really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Activity
laurahsisson commentedon Aug 10, 2022
Also running into this issue when trying to use
stream()on a collectionMy sense is that there is some kind of version conflict between the latest version of
google-cloud-firestoreandgoogle-api-core. In other words,google-cloud-firestoreis calling to some deprecated or remove behavior on the_UnaryStreamMultiCallable.Any advice on how to fix or avoid this issue on failed calls?
This also seems to be popping up on Reddit.
EDIT:
I've been able to avoid this issue by just passing in my own
google.api_core.retry.Retryobject.See the example provided here.
victorkingi commentedon Sep 2, 2022
I have this issue as well. I hope a solid fix comes along soon
YannLevavasseur commentedon Sep 6, 2022
Previous fix with retry object doesn't work in my case.
Did someone were able to fix this issue ?
victorkingi commentedon Sep 6, 2022
I don't think so, the devs have been slow in replying to this open issue. I found the bug through fuzzing with atheris fuzzer
victorkingi commentedon Sep 11, 2022
I found an easy fix before the devs give us an official reply.
Wrap the call to
db.collection("COLLECTION_NAME").stream()in a try except block which exceptsAttributeError. In the except block, calldb.collection("COLLECTION_NAME").stream()again. Wrap the whole of that in a function and you've got a recursive call to stream everytime it fails. If successful, the function returns the query snapshot.You can add a maximum number of retries before reporting the failure.
efroemling commentedon Dec 7, 2022
Just started running into this issue myself too. In my case it is from simply streaming through a large collection of documents; no writes/deletes/etc. happening.
This is on an Ubuntu 18 LTS system with Python 3.10.8, google-api-core 2.11.0, and google-cloud-firestore 2.7.2
rbngz commentedon Dec 28, 2022
I have the same issue. Some of my production servers suddenly started throwing this exception. Hope this will get fixed soon
meredithslota commentedon Jun 5, 2023
The current requirements for this library and
google-api-core[grpc]are:For anyone still experiencing this issue, can you confirm the versions that you're using? https://github.com/googleapis/python-api-core/releases/tag/v2.11.0 contains some fixes that likely help with this issue.
efroemling commentedon Jan 19, 2024
Hi. I hadn't seen this error show up in a while so I assumed maybe it was fixed, but I just added some code that is streaming through a large set of documents and it appears I am running into it again. The following is the stack trace from my app-engine app where it is happening, and also the list of pip packages from that same app-engine setup. This includes google-api-core 2.15.0 at this point, so it doesn't seem that 2.11.0 fixed it.
Is anyone else still seeing this? Should this be reopened?