I have firebase app with over a hundred Google Cloud functions that were working without issue. After some development and testing using the Firebase emulator, I deployed the changes to production. Post-deployment, every single function began throwing the following error:
Unhandled error Error: 13 INTERNAL: Received RST_STREAM with code 2 triggered by internal client error: Protocol error
Here's the full error with details:
handleUserSignInzn8bkxir2zxo Unhandled error Error: 13 INTERNAL: Received RST_STREAM with code 2 triggered by internal client error: Protocol error
at callErrorFromStatus (/workspace/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
at Object.onReceiveStatus (/workspace/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client.js:357:73)
at Object.onReceiveStatus (/workspace/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181)
at /workspace/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/resolving-call.js:94:78
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
for call at
at ServiceClientImpl.makeServerStreamRequest (/workspace/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/client.js:340:32)
at ServiceClientImpl.<anonymous> (/workspace/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
at /workspace/node_modules/@google-cloud/firestore/build/src/v1/firestore_client.js:227:29
at /workspace/node_modules/google-gax/build/src/streamingCalls/streamingApiCaller.js:38:28 at /workspace/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16
at Object.request (/workspace/node_modules/google-gax/build/src/streamingCalls/streaming.js:130:40)
at Timeout.makeRequest [as _onTimeout] (/workspace/node_modules/retry-request/index.js:141:28)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7)
Caused by: Error
at Firestore.getAll (/workspace/node_modules/@google-cloud/firestore/build/src/index.js:1028:23)
at DocumentReference.get (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:232:32)
at /workspace/lib/Users/handleUserSignIn.js:52:40
at fixedLen (/workspace/node_modules/firebase-functions/lib/v1/providers/https.js:74:41)
at /workspace/node_modules/firebase-functions/lib/common/providers/https.js:458:32
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { code: 13, details: 'Received RST_STREAM with code 2 triggered by internal client error: Protocol error', metadata: Metadata { internalRepr: Map(0) {}, options: {} } }
Here are some steps I've already taken to troubleshoot:
- Reverted to an earlier commit that was known to be working in production before any emulator work, then redeployed. The issue persists.
- Checked environment configurations to ensure that emulator settings were not inadvertently applied to the production environment.
- Updated all related dependencies (firebase-admin, google-gax, @grpc/grpc-js, etc.) to their latest versions.
- Ensured that my Firestore queries and functions do not exceed any known limits or best practices that might trigger such errors.
Could someone please help me figure out what's causing this error?
I was able to solve the issue.
For anyone stumbling on this post in the future with the same issue, I had the following variable in my
.envfile that I needed to comment. I figured this wouldn't cause any issues because it's not referenced anywhere but Firestore was still trying to use it: