question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[functions.config()] is EMPTY when running [firebase serve] or [firebase deploy] (using Node.js v10 function environment)

See original GitHub issue

Related issues

I know some people have complained about this in the past but I can’t seem to get this working.

[REQUIRED] Version info

node: v10.15.0

firebase-functions: ^3.0.0

firebase-tools:

firebase: 7.3.2

firebase-admin: ^8.0.0

[REQUIRED] Test case

running firebase serve fails to read functions.config()

[REQUIRED] Steps to reproduce

I’ve tried:

  • firebase functions:config:get > .runtimeconfig.json (creates the .json file with my expected config values)
  • firebase functions:config:get | ac .runtimeconfig.json (creates the .json with NO config values, just empty .json) - so i have to manually set the file in this case
  • I’ve tried putting the .runtimeconfig.json in the functions folder
  • I’ve tried putting the .runtimeconfig.json in the src folder
  • I’ve tried putting the .runtimeconfig.json in the src & the functions folder

[REQUIRED] Expected behavior

Running firebase serve should read functions.config()

[REQUIRED] Actual behavior

functions.config() seems to always be empty

This is the location that the code should read functions.config() values

TypeError: Cannot read property ‘secret’ of undefined at Object.<anonymous> (C:\Development\stripe\functions\lib\config.js:13:49) at Module._compile (internal/modules/cjs/loader.js:689:30) at Object.Module._extensions…js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) at Object.<anonymous> (C:\Development\stripe\functions\lib\source.js:5:18) at Module._compile (internal/modules/cjs/loader.js:689:30)

Were you able to successfully deploy your functions?

No… running firebase deploy --only functions gives me the exact same error. If I replace functions.config().myValue with the actual value, both firebase serve and firebase deploy work - but this isn’t the intended behavior… I don’t want my secret key value exposed in the code

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:24 (8 by maintainers)

github_iconTop GitHub Comments

11reactions
JFGHTcommented, Nov 29, 2019

In my case firebase functions:config:get | ac .runtimeconfig.json does generate a .runtimeconfig.json filled with all properties but still, the serve doesn’t load them.

This only happens in Windows 10.

Edit: looks like the first time I used firebase functions:config:get > .runtimeconfig.json and the invisible characters remained there even though I later used the ac command. Solution was to remove the file and create it again.

10reactions
samtsterncommented, Dec 16, 2019

Hmmm yeah I am seeing this too but interestingly I can fix it like this:

$ CLOUD_RUNTIME_CONFIG=$(pwd)/functions/.runtimeconfig.json firebase emulators:start

So I think there may be something going wrong in firebase-functions, but I will keep investigating.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running Cloud Functions locally gives error "functions.config ...
If, like me, you got this error while trying to run your functions locally then it's because functions.config() is only available within the ......
Read more >
Manage functions | Cloud Functions for Firebase - Google
You can deploy, delete, and modify functions using Firebase CLI commands or by setting runtime options in your functions source code. Deploy functions....
Read more >
Running Cloud Functions Locally Gives Error ... - ADocLib
To use the Cloud Functions emulator, first install the Firebase CLI: command to get your custom config (run this within the functions directory)...
Read more >
Fixing the Firebase Functions Configuration Loading Issues
When firebase deploy runs, it will automatically pick any .env.<project_or_alias_name> file that matches the active project. The settings in ...
Read more >
Smooth local Firebase development setup with ... - codechips
The fix is easy. We just need to change the type of our Firebase cloud function to callable. Firebase will then call it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found