firestore: service is Unavailable on every Next() call yet iterator never terminates
Client
Firestore
Environment
go version go1.24.6 darwin/arm64
Code and Dependencies
iter := ... .Documents(ctx)
doc, err := iter.Next()
// error here is "service unavailable". repeatedly for every call.
// but further .Next() calls never return `iterator.Done`
// this can cause **infinite** calls to this service
please fix
When you call Documents(ctx) on a Query or CollectionRef, you get a DocumentIterator that is backed by a queryDocumentIterator. The next() method of queryDocumentIterator streams results from the RunQuery RPC. If a Recv() call on this stream fails with a non-EOF error (like "service unavailable"), the error is returned and the iterator is permanently "poisoned" with that error. Subsequent calls to Next() will just return the cached error, and there are no infinite calls to the service. While this means the iterator never returns iterator.Done, it also doesn't cause an infinite retry loop in the client library itself.
thank god, we don't infinitely call backend at least!
Subsequent calls to Next() will just return the cached error, and there are no infinite calls to the service.
not true! we just observed that it does not! it infinitely calls iterator!