What is the reason for firebase functions deploy crashing - firebase

When deploying via firebase deploy --only functions I recently get the following error messages:
In the console:
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (90.26 KB) for uploading
✔ functions: functions folder uploaded successfully
i functions: updating Node.js 6 function firestoreEmail(us-central1)...
i functions: updating Node.js 6 function apiMain(us-central1)...
✔ functions[apiMain(us-central1)]: Successful update operation.
⚠ functions[firestoreEmail(us-central1)]: Deployment error.
Error setting up the execution environment for your function. Please try deploying again after a few minutes.
Functions deploy had errors. To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
In the log:
{"#type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":13,"message":"Error setting up the execution environment for your function. Please try deploying again after a few minutes."},"authenticationInfo":{"principalEmail":"myemail#gmail.com"},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"projects/myproject/locations/us-central1/functions/firestoreEmail"}

Related

Firebase Functions deploy had errors with the following functions

I am trying to deploy firebase functions and it gives below errors:
PS D:\projects\functions> yarn deploy
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
+ functions: required API cloudbuild.googleapis.com is enabled
+ functions: required API cloudfunctions.googleapis.com is enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (54.39 KB) for uploading
+ functions: functions folder uploaded successfully
i functions: creating Node.js 16 function geoCodeByGoogle(us-central1)...
i functions: creating Node.js 16 function placesByGoogle(us-central1)...
Functions deploy had errors with the following functions:
geoCodeByGoogle(us-central1)
placesByGoogle(us-central1)
i functions: cleaning up build files...
Error: There was an error deploying functions:
- Error Failed to create function geoCodeByGoogle in region us-central1
- Error Failed to create function placesByGoogle in region us-central1
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I tried,
Deleting functions form CLI
Tried changing the region and redeployed but still does not work as it is going to previous region settings.
3.Deleting Node modules
4.Renaming functions
5.Deleting functions from console
6.Redploying
Nothing worked.
Any idea guys, how to resolve it?
Thanks
Found the answer,
Just tried to print logs by hitting firebase functions:log which gave what was missed. In my case #googlemaps/google-maps-services-js was missing. I added and it worked.
Do this in beginning:- npm install -g firebase-tools
npm i -g firebase tools. Don't forget to do this.

How do firebase deploy?

i have problem with firebase deploy, execute the command in VS Code, showing me the next message,
I tried install, unistall dependency and no is the solution.
Thanks
Terminal:
jonatan#Jona:~/KOA/s2i-backoffice-web$ firebase deploy
=== Deploying to 'proyecto-s2i'...
i deploying functions, hosting
⚠ functions: package.json indicates an outdated version of firebase-functions.
Please upgrade using npm install --save firebase-functions#latest in your functions directory.
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔ functions: required API cloudbuild.googleapis.com is enabled
✔ functions: required API cloudfunctions.googleapis.com is enabled
i hosting[proyecto-s2i]: beginning deploy...
i hosting[proyecto-s2i]: found 263 files in public
✔ hosting[proyecto-s2i]: file upload complete
Error: An unexpected error has occurred.
File firebase-debug.log, this is the message
[debug] [2021-07-01T15:17:30.726Z] TypeError: Canno t read property 'length' of undefined
at Object.functionMatchesAnyGroup (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/functionsDeployHelper.js:11:23)
at have.filter (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/deploymentPlanner.js:25:56)
at Array.filter (<anonymous>)
at calculateRegionalFunctionChanges (/usr /local/lib/node_modules/firebase-tools/lib/deploy/functions/deploymentPlanner.js:25:17)
at Object.createDeploymentPlan (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/deploymentPlanner.js:53:50)
at release (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/release.js:24:48)
at process._tickCallback (internal/process/next_tick.js:68:7)
[error]
[error] Error: An unexpected error has occurred.
I had the same error with a fresh install.
I saw that firebase init had created a file at functions/index.js
However, the sole defined function inside that is commented out.
Uncommenting, and exporting a function resolved this issue.
Looks like you are uploading a bunch of files, do you need functions?
If you chose 'functions' during init, but did not define any, try this.
I just run into the exact issue. As hinted by #Sumit, After adding explicit use in code to functions, the issue solved.
exports.scheduledFunction = functions.pubsub.schedule('every 5 hours').onRun((context) => {
console.log('This will be run every 5 hours!');
});

Firebase Cloud Function deployment failed

It seems there is an issue with the Firebase server since the Google Services server downed this December 2020. I can no longer deploy my functions properly, 2 out of 20 deployment only succeed and the rest failed. We already put the issue from Github but it seems there is no team active in the repo.
How can we fixed this as the issue was almost a week now ?
So far this is the latest result after deployment.
+ 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: required API cloudbuild.googleapis.com is enabled
+ functions: required API cloudfunctions.googleapis.com is enabled
i functions: preparing Desktop\Projects\Firebase Functions\AdRenture Functions directory for uploading...
i functions: packaged Desktop\Projects\Firebase Functions\AdRenture Functions (20.24 KB) for uploading
There was an issue deploying your functions. Verify that your project has a Google App Engine instance setup at https://console.cloud.google.com/appengine and try again. If this issue persists, please contact support.
! functions: Upload Error: Server Error. read ECONNRESET
Error: Server Error. read ECONNRESET
Error but not all function which is somewhat common before but now it always occur.
i functions: updating Node.js 10 function acceptRentRequest(us-central1)...
i functions: updating Node.js 10 function deleteFacebookUser(us-central1)...
+ functions[validateCredential(us-central1)]: Successful update operation.
+ functions[deleteFacebookUser(us-central1)]: Successful update operation.
+ functions[approvePartnership(us-central1)]: Successful update operation.
+ functions[getList(us-central1)]: Successful update operation.
! functions[acceptRentRequest(us-central1)]: Deployment error.
Server Error. read ECONNRESET
! functions[approveRentRequest(us-central1)]: Deployment error.
Server Error. read ECONNRESET
! functions[announcement(us-central1)]: Deployment error.
Server Error. read ECONNRESET
Functions deploy had errors with the following functions:
acceptRentRequest
announcement
approveRentRequest
To try redeploying those functions, run:
firebase deploy --only "functions:acceptRentRequest,functions:announcement,functions:approveRentRequest"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.

firebase serve: supervisorPort (5001) is already in use

I built this React App, that allows users to add todo item, and mark an item as completed/active. Todo items are stored in cloud firestore.
I want to enable full-text search on the app, and one way is to create a cloud function that writes index to Algolia whenever cloud firestore witnesses a create operation.
Inside my app root directory, I initialize cloud functions and then implement the onTodoAdded function. After done, I run firebase serve under functions directory and get the errors:
=== Serving from '/Users/evan/source/react-redux-todos'...
i functions: Preparing to emulate functions.
Warning: You're using Node.js v10.6.0 but Google Cloud Functions only supports v6.11.5.
i hosting: Serving hosting files from: build
✔ hosting: Local server: http://localhost:5000
error: SUPERVISOR error Error: listen EADDRINUSE 127.0.0.1:5001
at Server.setupListenHandle [as _listen2] (net.js:1335:14)
at listenInCluster (net.js:1383:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1509:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:61:10)
error: supervisorPort (5001) is already in use
i functions: No HTTPS functions found. Use firebase functions:shell if you would like to emulate other types of functions.
For a complete debug log, find here.
However, this command works fine: firebase serve --only functions.
=== Serving from '/Users/evan/source/react-redux-todos'...
i functions: Preparing to emulate functions.
Warning: You're using Node.js v10.6.0 but Google Cloud Functions only supports v6.11.5.
i functions: No HTTPS functions found. Use firebase functions:shell if you would like to emulate other types of functions.
Since it says supervisorPort(5001) is already in use, I lsof -i:5001 and finds no process. I also shut down my laptop and restart, gets the same error.
I find the similar issue here, however didn't find the solution.
I still don't know the reason, but adding --port=9000 solves the problem. For example, firebase serve --only functions --port=9000. Credits to restPort (5001) is already in use #142.
I was having this same error after updating to macOS Mojave 10.14.1 (was fine with 10.14). error: supervisorPort (5001) is already in use and it led me down this rabbit hole of additional updates and configuration that eventually got it to work.
1 Update Node Packages
I updated these items to these versions (latest as of this writing)
firebase-functions: 2.1.0
firebase: 5.5.8
I deleted by node_modules folder and reinstalled all the packages.
2 Firestore Emulator Setup Required
Next time I attempted to serve, firebase gave me this error:
Setup required, please run: firebase setup:emulators:firestore
Because of the weird permissions issues I initially had with mac, I actually have to run
node_modules/.bin/firebase setup:emulators:firestore
3 Then.... Fix Java Runtime Issues
On my next serve attempt, I was presented with firestore: No Java runtime present, requesting install. Mac presents a popup leading to a page where you can "download java for mac". This isn't what you actually need. You really need the Java SE Development Kit which enables command line interface.
Then... You may get these errors the next time you try to serve.
error: restPort (5002) is already in use
error: SUPERVISOR error Error: listen EADDRINUSE 127.0.0.1:5001
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at Server.setupListenHandle [as _listen2] (net.js:1351:14)
at listenInCluster (net.js:1392:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1501:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:10)
error: supervisorPort (5001) is already in use
But Firebase still ended up continuing to successfully serve somehow, despite these errors. And it still shows my app over http://localhost:5000.
Hope this helps!

Issue while creating fire base function

Tried creating a firebase function but after deployment i am getting prj url rather than function url,as shown in the firebase link https://firebase.google.com/docs/functions/get-started
logs:
functions: Finished running predeploy script.
i functions: ensuring necessary APIs are enabled...
functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (36.94 KB) for uploading
functions: functions folder uploaded successfully
i functions: creating function makeUppercase...
functions[makeUppercase]: Successful create operation.
Deploy complete!
Project Console: https://console.firebase.google.com/project/prjname-faf3a/overview

Resources