Comments (26)
Hm, I found out that init created a new functions folder in the root with the necesary package.json and node_modules folder. So I copied those except the index.js to the /firebase/functions folder.
Then tried to deploy again.
Got error agsain because of missing packages.
Had to install the following packages:
firebase-function-tools
@firebase/[email protected]
nodemailer
mkdirp-promise
child-process-promise
Now I could deploy.
11 warning about code in the function:
/firebase/functions/auth/onDelete.f.js
3:8 warning 'moment' is defined but never used no-unused-vars
/firebase/functions/db/groupChats/name/onUpdate.f.js
18:34 warning Array.prototype.map() expects a return value from arrow function array-callback-return
/firebase/functions/db/userChatMessages/onCreate.f.js
27:11 warning 'senderRef' is assigned a value but never used no-unused-vars
/firebase/functions/https/admin/onCall.f.js
9:38 warning Unexpected string concatenation of literals no-useless-concat
/firebase/functions/https/api/companies/onRequest.f.js
6:5 warning 'whitelist' is assigned a value but never used no-unused-vars
/firebase/functions/https/api/users/onRequest.f.js
6:5 warning 'whitelist' is assigned a value but never used no-unused-vars
/firebase/functions/https/messages/onCall.f.js
8:38 warning Unexpected string concatenation of literals no-useless-concat
/firebase/functions/https/usersSync/onCall.f.js
18:40 warning Unexpected string concatenation of literals no-useless-concat
/firebase/functions/storage/onFinalize.f.js
2:8 warning 'admin' is defined but never used no-unused-vars
/firebase/functions/storage/thumbnails.js
4:1 warning Unexpected default export of anonymous function import/no-anonymous-default-export
/firebase/functions/utils/splitStringToArray.js
38:12 warning 'i' is already defined no-redeclare
✖ 11 problems (0 errors, 11 warnings)
Then lots of Error
Error: There was an error deploying functions:
- Error Failed to create function auth-onCreate in region us-central1
- Error Failed to create function db-userChatMessagesOnUpdate in region us-central1
- Error Failed to create function db-roleGrantsOnWrite in region us-central1
- Error Failed to create function https-apiCompaniesOnRequest in region us-central1
- Error Failed to create function https-usersSyncOnCall in region us-central1
- Error Failed to create function https-adminOnCall in region us-central1
- Error Failed to create function db-publicChatsOnCreate in region us-central1
- Error Failed to create function db-groupChatsMembersOnCreate in region us-central1
- Error Failed to create function db-rolesOnWrite in region us-central1
- Error Failed to create function db-usersCountOnDelete in region us-central1
- Error Failed to create function db-usersOnWrite in region us-central1
- Error Failed to create function https-apiUsersOnRequest in region us-central1
- Error Failed to create function auth-onDelete in region us-central1
- Error Failed to create function db-triggersOnCreate in region us-central1
- Error Failed to create function db-groupChatsMembersOnDelete in region us-central1
- Error Failed to create function https-messagesOnCall in region us-central1
- Error Failed to create function db-groupChatsNameOnUpdate in region us-central1
- Error Failed to create function db-userRolesOnWrite in region us-central1
- Error Failed to create function db-adminsOnWrite in region europe-west1
- Error Failed to create function db-userChatMessagesOnCreate in region europe-west1
- Error Failed to create function storage-onFinalize in region europe-west1
- Error Failed to create function db-groupChatMessagesOnCreate in region europe-west1
- Error Failed to create function db-userGrantsOnWrite in region europe-west1
from react-most-wanted.
Region is hard coded in some of the functions..
from react-most-wanted.
Are those functions tested?
from react-most-wanted.
Fixed the second warning in onUpdate.f.js:
Changed map(() => {}) to map(() => ())
With () - implicit return takes place.
from react-most-wanted.
Hm, warnings and the failed to create does not seem to be related. for example auth-onCreate has no warnings but fails to deploy.
from react-most-wanted.
I have 45 of these in my firebase-debug.log:
failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause:
Checked the logs at: console.cloud.google.com/logs
severity: "ERROR"
textPayload: "Function cannot be initialized. Error: function terminated. Recommended action: inspect logs for termination reason. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging
"
timestamp: "2022-03-25T11:52:20.862903625Z"
I could not find the termination reason in the vast amount of errors.
from react-most-wanted.
The issue must be with the hard coded regions. You can not change a region for a project after it's created. So I am trying to change region to where my project is deployed.
from react-most-wanted.
Hm, it still deploys in us-central even when I have changed the hardcoded values with my own multi eu3 region.
? Would you like to proceed with deletion? Selecting no will continue the rest of the deployments. Yes
i functions: updating Node.js 16 function auth-onCreate(us-central1)...
i functions: updating Node.js 16 function auth-onDelete(us-central1)...
i functions: updating Node.js 16 function db-groupChatsMembersOnCreate(us-central1)...
i functions: updating Node.js 16 function db-groupChatsMembersOnDelete(us-central1)...
i functions: updating Node.js 16 function db-groupChatsNameOnUpdate(us-central1)...
i functions: updating Node.js 16 function db-publicChatsOnCreate(us-central1)...
i functions: updating Node.js 16 function db-roleGrantsOnWrite(us-central1)...
i functions: updating Node.js 16 function db-rolesOnWrite(us-central1)...
i functions: updating Node.js 16 function db-triggersOnCreate(us-central1)...
i functions: updating Node.js 16 function db-userChatMessagesOnUpdate(us-central1)...
i functions: updating Node.js 16 function db-userRolesOnWrite(us-central1)...
i functions: updating Node.js 16 function db-usersOnWrite(us-central1)...
i functions: updating Node.js 16 function db-usersCountOnDelete(us-central1)...
i functions: updating Node.js 16 function https-adminOnCall(us-central1)...
i functions: updating Node.js 16 function https-apiCompaniesOnRequest(us-central1)...
i functions: updating Node.js 16 function https-apiUsersOnRequest(us-central1)...
i functions: updating Node.js 16 function https-messagesOnCall(us-central1)...
i functions: updating Node.js 16 function https-usersSyncOnCall(us-central1)...
i functions: creating Node.js 16 function db-adminsOnWrite(eur3)...
i functions: creating Node.js 16 function db-groupChatMessagesOnCreate(eur3)...
i functions: creating Node.js 16 function db-userChatMessagesOnCreate(eur3)...
i functions: creating Node.js 16 function db-userGrantsOnWrite(eur3)...
i functions: creating Node.js 16 function storage-onFinalize(eur3)...
i functions: deleting Node.js 16 function db-adminsOnWrite(europe-west1)...
i functions: deleting Node.js 16 function db-groupChatMessagesOnCreate(europe-west1)...
i functions: deleting Node.js 16 function db-userChatMessagesOnCreate(europe-west1)...
i functions: deleting Node.js 16 function db-userGrantsOnWrite(europe-west1)...
i functions: deleting Node.js 16 function storage-onFinalize(europe-west1)...
⚠ functions: failed to create function projects/urk/locations/eur3/functions/db-adminsOnWrite
✔ functions[db-adminsOnWrite(europe-west1)] Successful delete operation.
✔ functions[storage-onFinalize(europe-west1)] Successful delete operation.
✔ functions[db-userGrantsOnWrite(europe-west1)] Successful delete operation.
✔ functions[db-groupChatMessagesOnCreate(europe-west1)] Successful delete operation.
✔ functions[db-userChatMessagesOnCreate(europe-west1)] Successful delete operation.
from react-most-wanted.
Are the database, strage, hostin and auth services enabled in your project?
from react-most-wanted.
yes, only. functions that i haven't tried before. But they are getting deployd to the wrong regions
from react-most-wanted.
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 firebase/functions directory for uploading...
i functions: packaged firebase/functions (53.38 KB) for uploading
✔ functions: firebase/functions folder uploaded successfully
from react-most-wanted.
functions: failed to create function projects/test/locations/eur3/functions/db-adminsOnWrite
from react-most-wanted.
and the region that the project is set to seems not working
from react-most-wanted.
regions seems a bit random?
from react-most-wanted.
is there more hidden regions in the code? this is a real mess.. :-)
Why are the functions by default deployd to us-central1 and europe-west1?
from react-most-wanted.
found some edge cases:
Here's a mapping of the closest functions-supported regions for Cloud Firestore and Cloud Storage, for cases where the same region is not supported:
eur3 or europe-west (multi-region) | europe-west1 |
---|
Important: If you are using HTTP functions to serve dynamic content for Firebase Hosting, you must use us-central1.
from react-most-wanted.
Ok, I will try to add this to all the functions:
exports.myStorageFunction = functions
.region('europe-west1')
.storage
.object()
.onFinalize((object) => {
// ...
});
from react-most-wanted.
You can also remove all regions.
from react-most-wanted.
Tried a complete deploy.
✖ 10 problems (0 errors, 10 warnings)
✔ functions: Finished running predeploy script.
i database: checking rules syntax...
✔ database: rules syntax for database tbvpoc-default-rtdb is valid
i firebase.storage: checking firebase/storage.rules for compilation errors...
✔ firebase.storage: rules file firebase/storage.rules compiled successfully
i firestore: reading indexes from firebase/firestore.indexes.json...
i cloud.firestore: checking firebase/firestore.rules for compilation errors...
⚠ [W] undefined:undefined - Ruleset uses old version (version [1]). Please update to the latest version (version [2]).
⚠ [W] 13:14 - Invalid function name: exists.
⚠ [W] 13:63 - Invalid variable name: request.
⚠ [W] 18:15 - Invalid function name: get.
⚠ [W] 18:66 - Invalid variable name: request.
⚠ [W] 22:14 - Unused function: isGranted.
⚠ [W] 28:14 - Unused function: isOwner.
⚠ [W] 29:14 - Invalid variable name: request.
✔ cloud.firestore: rules file firebase/firestore.rules compiled successfully
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔ functions: required API cloudfunctions.googleapis.com is enabled
✔ functions: required API cloudbuild.googleapis.com is enabled
i storage: latest version of firebase/storage.rules already up to date, skipping upload...
✔ firestore: deployed indexes in firebase/firestore.indexes.json successfully
i firestore: latest version of firebase/firestore.rules already up to date, skipping upload...
i hosting[tbvpoc]: beginning deploy...
i hosting[tbvpoc]: found 15 files in public
✔ hosting[tbvpoc]: file upload complete
i database: releasing rules...
✔ database: rules for database tbvpoc-default-rtdb released successfully
✔ storage: released rules firebase/storage.rules to firebase.storage
✔ firestore: released rules firebase/firestore.rules to cloud.firestore
i functions: cleaning up build files...
i hosting[tbvpoc]: finalizing version...
✔ hosting[tbvpoc]: version finalized
i hosting[tbvpoc]: releasing new version...
✔ hosting[tbvpoc]: release complete
✔ Deploy complete!
But I can't find any functions in the console..
from react-most-wanted.
You can sheck what projects you have in in your firebase.src file. Also update the firebase rules to version 2.
from react-most-wanted.
Yes, updated firebase rules to v2.
Still got invalid functions names:
i cloud.firestore: checking firebase/firestore.rules for compilation errors...
⚠ [W] 14:14 - Invalid function name: exists.
⚠ [W] 14:63 - Invalid variable name: request.
⚠ [W] 19:15 - Invalid function name: get.
⚠ [W] 19:66 - Invalid variable name: request.
⚠ [W] 23:14 - Unused function: isGranted.
⚠ [W] 29:14 - Unused function: isOwner.
⚠ [W] 30:14 - Invalid variable name: request.
from react-most-wanted.
Those look like error messages for code inside the function. Did you change any code or is it from the template?
from react-most-wanted.
I only added rules_version = "2"; to the firestore.rules file.
No changes other than that and yes it's from the template.
from react-most-wanted.
✔ functions: Finished running predeploy script.
i database: checking rules syntax...
✔ database: rules syntax for database tbvpoc-default-rtdb is valid
i firebase.storage: checking firebase/storage.rules for compilation errors...
✔ firebase.storage: rules file firebase/storage.rules compiled successfully
i firestore: reading indexes from firebase/firestore.indexes.json...
i cloud.firestore: checking firebase/firestore.rules for compilation errors...
⚠ [W] 14:14 - Invalid function name: exists.
⚠ [W] 14:63 - Invalid variable name: request.
⚠ [W] 19:15 - Invalid function name: get.
⚠ [W] 19:66 - Invalid variable name: request.
⚠ [W] 23:14 - Unused function: isGranted.
⚠ [W] 29:14 - Unused function: isOwner.
⚠ [W] 30:14 - Invalid variable name: request.
✔ cloud.firestore: rules file firebase/firestore.rules compiled successfully
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 storage: latest version of firebase/storage.rules already up to date, skipping upload...
✔ firestore: deployed indexes in firebase/firestore.indexes.json successfully
i firestore: uploading rules firebase/firestore.rules...
i hosting[tbvpoc2]: beginning deploy...
i hosting[tbvpoc2]: found 15 files in public
✔ hosting[tbvpoc2]: file upload complete
i database: releasing rules...
✔ database: rules for database tbvpoc-default-rtdb released successfully
✔ storage: released rules firebase/storage.rules to firebase.storage
✔ firestore: released rules firebase/firestore.rules to cloud.firestore
i functions: cleaning up build files...
i hosting[tbvpoc2]: finalizing version...
✔ hosting[tbvpoc2]: version finalized
i hosting[tbvpoc2]: releasing new version...
✔ hosting[tbvpoc2]: release complete
✔ Deploy complete!
No functions is deployd..
from react-most-wanted.
If helpful, I had the same issue you described RE "Could not detect language" and I also attempted firebase init functions
which yielded the same deploy error.
After sniffing the firebase logs via the console looked like I was missing some npm packages.
I also noticed that the init
call from before overwrote my package.json
(or maybe I had done that manually when in a frenzy, I don't recall) for the functions and was using node 16 instead of node 14.
May not be the same issue you are having but, basically I just:
- deleted
node_modules
, and then overwrote thepackage.json
with a fresh version copied fromnpx create-react-app my-app --template rmw
npm install
firebase deploy --only functions
and it worked. I had also removed the hard coded regions.
Here is the fresh package.json I used (valid at the time of writing this):
https://gist.github.com/cwmat/b6333c5cc485346ca11693b64b439fdf
from react-most-wanted.
@cwmat thx for pointing that out. Yes the only way to get the latest function updates is to copy them from s fresh package. I'm thinking if maybe firebase extensions would be useful but in the end the flexibility is my main goal with this project to do with it after the template what you want.
from react-most-wanted.
Related Issues (20)
- Hello this is not a big issue, just personal issue HOT 1
- `npm install` fails HOT 1
- Consider generating source maps
- Generated app is not working HOT 2
- Generated app with --template rmw is not working
- Loading icon in rmw-shell template is not centered
- MUI Shell template has a compile error immediately
- Handle routes for react-dom v6 HOT 5
- Generating app with --template rmw intl-relativetimeformat dependency HOT 10
- Can't resolve './config' HOT 1
- Testing tools, Cypress, RTL HOT 1
- Can't login to app HOT 11
- RTL Mode
- rmw template fails to install "Conflicting peer dependency" HOT 4
- redirect to previous authenticated path after signing in
- I'm no able to install this template with `npx create-react-app` HOT 13
- npx create-react-app error HOT 11
- Firebase Phone number authentication not working
- Menu - Auth menu list items not rendering when within nested list items
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-most-wanted.