firebase-functions: FIREBASE_CONFIG not set when Node.js 10 function deployed
[REQUIRED] Environment info
firebase-tools: 6.8.0
Platform: Windows 10
[REQUIRED] Test case
I had a set of functions built using Node.js version 6. They were successfully deployed and running.
I took the following actions to upgrade to use a newer version of Node:
– Upgraded my Windows development system to Node.js version 10.15.3
– Upgraded to latest Firebase tools: npm install -g firebase-tools
– Upgraded Firebase SDK: npm install firebase-functions@latest firebase-admin@latest --save
– Edited the project’s package.json
file to include "engines" : { "node" : "10" }
With those changes, the firebase deploy --only functions
command completed without error. However, immediately after deployment, an error log appeared in the Firebase console for each function: Warning, FIREBASE_CONFIG environment variable is missing. Initializing firebase-admin will fail
.
Changing package.json file
to specify version 8 instead of 10 resolved the problem: "engines" : { "node" : "8" }
. Functions initialize and execute as expected.
[REQUIRED] Steps to reproduce
Described in test case
[REQUIRED] Expected behavior
Firebase tools should set FIREBASE_CONFIG to the appropriate default for the project.
[REQUIRED] Actual behavior
FIREBASE_CONFIG is not set if Node version of 10 is specified in package.json
file.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 19
- Comments: 28 (10 by maintainers)
The fix has been rolled out to production.
FIREBASE_CONFIG
andfunctions.config()
should now work properly in Node 10 runtime. Please let me know if anyone is still seeing issues. Thanks!Quick update: we have identified and implemented the fix for unpopulated
FIREBASE_CONFIG
andfunctions.config()
values. This should roll out to production sometime next week.@MaximBazarov @peterpeterparker your issues are likely different and relating to
GCLOUD_PROJECT
environment variable missing from the Node 10 runtime (although it should work fine with Node 8). Please open a new issue about this.Thanks @rilian for that report as well - these issues are connected since both
functions.config()
andFIREBASE_CONFIG
are populated by reading in the.runtimeconfig.json
file, which the SDK can no longer find in the Node 10 runtime.While I have a pending SDK fix for this, upon further investigating, I think this is a bug in the functions backend, and should be fixed there (see https://github.com/firebase/firebase-functions/pull/434#issuecomment-490168973). We are working with the relevant teams to resolve these issues. Thanks for everyone’s patience!
Just to confirm, I see same error on https callable functions after upgrading to node 10
Same here, with Node v8 all fine, when I upgrade to Node v10 I get the following error which I provide with the stack trace I found in the Firebase console in case that would help:
Update firebase-tools
@rilian they serve different purposes.
functions.config()
is used if you’re storing some custom key value pairs. To set the keys, you would dofirebase functions:config:set some-service.key=value
. To use that value in your functions code, retrieve it as you did withfunctions.config().some-service.key
(see these docs for more info).FIREBASE_CONFIG
is something that you shouldn’t need to worry about - it is automatically populated with your project information and allows you to use the Firebase Admin SDK to talk to Firebase, RTDB, or Storage, for example:These docs provide more info on what
FIREBASE_CONFIG
looks like.Does that help?
For those as me who had this annoying problem here comes the solution…
For some stupid reason firebase forces you to have this environment variables set EVEN IF YOU DON’T USE THEM (what was my case). to fix it you have 2 options
1- open google cloud functions -> click the function name -> edit -> add runtime variable -> them you have to manually inform the values of these two variables… THIS MUST BE DONE FOR EACH OF YOUR FUNCTIONS
2- you can copy paste the following code as the FIRST LINE of each of your firebase functions
ATTENTION!!!
the
FIREBASE_CONFIG
isn’t an object it is A STRING in json format so pay attention while setting it (these guys from firebase somethings do the dumbest things)after that you stop getting this error
This is a separate issue: https://github.com/firebase/firebase-functions/issues/437. Please follow that bug.