Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

ClientPool.clientFactory crashing in serverless environments #1929

@vdemcak

Description

@vdemcak

I'm trying to execute Firestore queries inside of Google Cloud Functions utilizing Qwik together with routeLoader$ in order to fetch and pre-render data server-side. Everything works fine in development and when using the preview command, but upon deploying the app to Firebase Hosting and Cloud Functions (Using the Firebase integration), the app returns Error 500 - Internal Server Error.

Upon opening the Cloud Function logs, I can see, that it fails with the following error message which leads me to believe, that there is something wrong with the @google-cloud/firestore and firebase-admin(Which utilizes this package under the hood as far as I know):

TypeError: Cannot set properties of undefined (setting 'fromParams')
    at ClientPool.clientFactory (file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:167322:43)
    at ClientPool.acquire (file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:153428:31)
    at ClientPool.run (file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:153535:28)
    at file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:168168:28
    at Firestore._retry (file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:168038:26)
    at async file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:145922:33
Caused by: Error
    at AggregateQuery._get (file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:145879:21)
    at AggregateQuery.get (file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:145869:19)
    at Object.s_eNFdi8qBn48 (file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:168225:68)
    at Object.invoke (file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:1461:42)
    at file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:4100:131
    at then (file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:137:81)
    at file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:4091:14
    at Object.qrl (file:///workspace/server/assets/@qwik-city-plan-c264a646.mjs:4071:18)
    at file:///workspace/server/entry-firebase.mjs:464:37
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"

Current Setup

// /lib/firestore.ts
import { Firestore } from '@google-cloud/firestore';

export const firestore = new Firestore({
  projectId: 'some-project',
  credentials: {
    client_email: '[email protected]',
    private_key: "supersecret"
  }
});


// /routes/challenges/index.tsx
import { firestore } from '~/lib/firestore';

export const useChallenges = routeLoader$(async () => {
  const countRes = await firestore.collection('challenges').count().get();

  return countRes.data();
});

export default component$(() => {
  const challenges = useChallenges();

  return (
    <div>
      <h1>Challenges</h1>
      <pre>{JSON.stringify(challenges.value, null, 2)}</pre>
    </div>
  );
});

Environment details

  System:
    OS: macOS 14.0
    CPU: (10) arm64 Apple M1 Pro
    Memory: 78.05 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.7.0 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.1.0 - /opt/homebrew/bin/npm
    pnpm: 8.9.2 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 118.0.5993.88
    Safari: 17.0
  npmPackages:
    @builder.io/qwik: ^1.2.13 => 1.2.13 
    @builder.io/qwik-city: ^1.2.13 => 1.2.13 
    @google-cloud/firestore: ^7.1.0 => 7.1.0 
    undici: 5.22.1 => 5.22.1 
    vite: 4.4.7 => 4.4.7 

Steps to reproduce

  • Start a new qwik project
  • Add and configure the Firebase integration
  • Add @google-cloud/firestore or firebase-admin package
  • Create a page with a routeLoader$ which executes Firestore queries
  • Upload to Firebase Hosting + Firebase Functions
  • Opening the route that utilizes routeLoader$ should result in an Error 500 - Internal Server Error.

Metadata

Metadata

Assignees

Labels

api: firestoreIssues related to the googleapis/nodejs-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