firebase-functions: Node 8 functions ending with "finished with status: 'connection error'"

Firebase function triggered by firestore trigger is ending prematurely with finished with status: 'connection error'. There are no errors logged from actual function. Phase where function is exiting is varying. Most of the functions (lighter functions, with less communication to firestore) are finishing ok.

When runtime is changed to “Node.js 10 Beta” functions are working correctly.

Region: europe-west1 Memory allocated: 1 GB Timeout: 300 seconds

Related issues

#429 (already closed)

[REQUIRED] Version info

node: node 8 (in cloud) v12.4.0 (locally)

firebase-functions: “firebase-functions”: “3.3.0”

firebase-tools: “firebase-tools”: “7.12.1”

7.12.1

firebase-admin: “firebase-admin”: “8.9.1”

[REQUIRED] Test case

have not been able to extract code to reproduce it outside of my codebase. I have case where this is happening 100% of executions.

[REQUIRED] Steps to reproduce

Run function which is querying multiple documents from firestore using firebase-admin.

repo for reproducing issue: https://github.com/diginikkari/case00032967

Reproduction steps:

  1. create firestore project
  2. Initialize firestore database for project
  3. get service account credentials and save it root folder with name: service-account.json
  4. build and deploy functions npm run build; npm run deploy
  5. generate fake test data npm run generate-fake-data
  6. call function which add order document to firestore, which then triggers the firestore function trigger npm run create-order-copy
  7. check logs npm run logs

When function is using “node 8” it will end with finished with status: 'connection error'. When changing to “node 10” function is ending finished with status: 'ok'

[REQUIRED] Expected behavior

Function is finished succesfully.

[REQUIRED] Actual behavior

Function is ending prematurely with finished with status: 'connection error' message.

Were you able to successfully deploy your functions?

Yes, there were no errors with deployment.

log from errored execution.txt

log_screenshot

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 10
  • Comments: 26

Most upvoted comments

We’re also experiencing this issue on a scheduled function that runs every minute. We first experienced the “connection error” result at 5:51pm PST on Jan 18th. As with the others in this thread, using the Node 10 Beta runtime fixes the issue, but that obviously is not an ideal solution.

@steven-tib I changed function runtime to node.js 10. This was desperate try because nothing else helped and for some reason it worked at least for me. So perhaps that is something you could try also.

I’m bit worried on using node.js 10 because it’s still in beta. But I figured that what I have to lose. I keep my functions in node 10 at least until this issue is solved.

I don’t think this has been fixed. It started happening to us of lately, with no code changes whatsoever. Just re-deploying those functions since we use automated deployments with Gitlab pipelines and have all functions deployed with every release. Firebase support team has no answers or acknowledgment of this problem just yet, very annoying. However our internal investigation points to the setup something similar to this comment from here https://github.com/firebase/firebase-functions/issues/611#issuecomment-578037659, where the problem is happening consistently.

  • Cloud Function Node runtime version 8
  • Deployment happening from a Gitlab Pipeline using docker image (https://hub.docker.com/r/partumgmbh/gcp-pipeline) with firebase-tools 7.14.0 and Node v10.19.0 installed
  • Cloud Function of type pubsub.schedule (which automatically creates a trigger in Google Cloud Scheduler)
  • Cloud Function returning either Promise.all or await Promise.all in all those connection error cases
  • Underlying promises arrays are mostly trivial write operations to either Firestore or BigQuery inserts, but a lot of them

Migrating to Node 10 is not the solution just yet as it has lot of other implications. We plan to do the migration during end of the year, but until then we want the Node 8 runtime for cloud functions to be running as before. This sudden platform bug is more than undesirable. Any help, workaround, suggestions would be more than welcome.

Two days ago, I deployed my clouds function again with minor changes in the code. I got ‘connection error’. After looking at the code, I saw that this error only happened in functions which are:

  • Scheduled functions (cronjob and pubsub)
  • Using await Promise.all() I decided to convert ‘Promise.all’ to ‘reduce’, then this error happens less, but still exists.

PS: I’m using Node 8

We had the issue too, having raised a support case with GCP, this has now been reported to us as resolved and we’re not seeing the error any more after having redpeloyed our node 8 funtctions.