Skip to content

ClientException: Connection closed before full header was received #291

Closed

Description

@OutdatedGuy

Describe the bug
When executing multiple firestore queries, few queries fail with below exceptions:

{"severity":"ERROR","message":"ClientException: Connection closed before full header was received, uri=https://firestore.googleapis.com/v1/projects/{project-id}/databases/(default)/documents:runQuery\npackage:http/src/io_client.dart 229:7                   IOClient.send\npackage:googleapis_auth/src/auth_http_utils.dart 43:22  AuthenticatedClient.send\npackage:google_cloud_rpc/service_client.dart 149:22     ServiceClient._makeStreamingRequest\n"}

Aggregate Count Query:

ClientException: Connection closed before full header was received, uri=https://firestore.googleapis.com/v1/projects/{project-id}/databases/(default)/documents/{collection}/{document-id}:runAggregationQuery

Where Query:

ClientException: Connection closed before full header was received, uri=https://firestore.googleapis.com/v1/projects/{project-id}/databases/(default)/documents:runQuery

I'm executing around 3K queries simultaneously using Future.wait

To Reproduce

import 'package:firebase_admin_sdk/firebase_admin_sdk.dart';
import 'package:firebase_functions/firebase_functions.dart';

void main() {
  runFunctions((firebase) {
    firebase.https.onRequest(name: 'clientException', (request) async {
      final arr = List.generate(3000, (index) => index);

      final firestore = FirebaseApp.instance.firestore();

      await Future.wait(
        arr.map((index) {
          return firestore
              .collection('numbers')
              .where('number', .equal, index)
              .limit(1)
              .get();
        }),
        eagerError: true,
      );

      return .ok('Yay! Client Exception did not occur.');
    });
  });
}

Expected behavior

No exception should be thrown randomly. The same code works in nodejs without any exceptions.

Activity

  1. demolaf commented on Jul 1, 2026

    @demolaf
    Member

    Hi @OutdatedGuy thanks for raising this. I was able to reproduce this and currently investigating, i'll keep this issue up to date.

  2. self-assigned this
    on Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions