Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error deploying Firebase Cloud Functions on Node runtime 10, but works on Node runtime 8

I am trying to implement geofirestore in my cloud functions.

The functions deploy correctly in Node runtime 8, but there is an error in deployment in runtime 10.

My index.js header is as below:

const functions = require("firebase-functions");
const admin = require("firebase-admin");
const { GeoCollectionReference, GeoFirestore, GeoQuery, GeoQuerySnapshot } = require('geofirestore');
admin.initializeApp();

const db = admin.firestore();
const geofirestore = new GeoFirestore(db);

The error message I get on Node runtime 10 is:

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint

> functions@ lint C:\Users\naabr\Projects\flutter\mg_sos\firebase\functions
> eslint .

+  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
!  functions: missing required API cloudbuild.googleapis.com. Enabling now...
+  functions: required API cloudfunctions.googleapis.com is enabled

!  functions: Cloud Functions will soon require the pay-as-you-go (Blaze) billing plan to deploy. To avoid service disruption, upgrade before 2020-06-23. For more information, see: https://firebase.google.com/support/faq#functions-runtime

i  functions: preparing functions directory for uploading...
i  functions: packaged functions (42.88 KB) for uploading
+  functions: functions folder uploaded successfully
i  functions: updating Node.js 10 function newUserCreated(us-central1)...
i  functions: updating Node.js 10 function emergencyNotification(us-central1)...
i  functions: updating Node.js 10 function emergencyUpdate(us-central1)...
!  functions[newUserCreated(us-central1)]: Deployment error.
Function failed on loading user code. Error message: Please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs
like image 485
Neil Brown Avatar asked May 24 '20 21:05

Neil Brown


People also ask

What version of node does firebase use?

Firebase Cloud Functions now supports Node 8.

How many requests can handle a single cloud function?

Cloud Run has the capability to handle up to 80 concurrent requests with the same instance. At the opposite, Cloud Functions create as many instances as the concurrent requests.


Video Answer


1 Answers

Go to the functions folder, then open package.json file. Now change the file as given below

"engines": {
"node": "10"
}

to

"engines": {
"node": "8"
}

Then, again deploy function.

like image 121
Faizan Haidar Khan Avatar answered Oct 29 '22 23:10

Faizan Haidar Khan