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.

process.env.FIREBASE_CONFIG is not populated

See original GitHub issue

[REQUIRED] Step 2: Describe your environment

  • Operating System version: Linux 7u 5.3.0-24-generic firebase/firebase-admin-node#26-Ubuntu SMP Thu Nov 14 01:33:18 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • Firebase SDK version: 7.10.0
  • Firebase Product: firebase-functions/firebase-admin
  • Node.js version: nodejs10 runtime
  • NPM version: 6.13.1

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

Relevant Code:

I was trying to adopt https://firebase.google.com/docs/functions/config-env#automatically_populated_environment_variables. Deploying firebase function (http) with:

if (process.env.FIREBASE_CONFIG === undefined) {
    throw new Error('Missing FIREBASE_CONFIG');
}
...
admin.initializeApp(opts);

makes deployment to fail.

From terminal:

$ firebase deploy --only functions:admin.forceRcUpdate ✔ scheduler: all necessary APIs are enabled ⚠ functions[admin-forceRcUpdate(us-central1)]: Deployment error. Error setting up the execution environment for your function. Please try deploying again after a few minutes.

In logs:

E 2019-12-16T07:16:02.599384474Z admin-forceRcUpdate Error: function terminated. Recommended action: inspect logs for termination reason. Function cannot be initialized. admin-forceRcUpdate
A 2019-12-16T07:15:58.840Z admin-forceRcUpdate Could not load the function, shutting down. admin-forceRcUpdate
A 2019-12-16T07:15:58.837Z admin-forceRcUpdate at Object.<anonymous> (/srv/node_modules/@google-cloud/functions-framework/build/src/index.js:67:33) admin-forceRcUpdate
A 2019-12-16T07:15:58.837Z admin-forceRcUpdate at Object.getUserFunction (/srv/node_modules/@google-cloud/functions-framework/build/src/invoker.js:57:32) admin-forceRcUpdate
A 2019-12-16T07:15:58.837Z admin-forceRcUpdate at require (internal/modules/cjs/helpers.js:22:18) admin-forceRcUpdate
A 2019-12-16T07:15:58.837Z admin-forceRcUpdate at Module.require (internal/modules/cjs/loader.js:637:17) admin-forceRcUpdate
A 2019-12-16T07:15:58.837Z admin-forceRcUpdate at Function.Module._load (internal/modules/cjs/loader.js:531:3) admin-forceRcUpdate
A 2019-12-16T07:15:58.837Z admin-forceRcUpdate at tryModuleLoad (internal/modules/cjs/loader.js:539:12) admin-forceRcUpdate
A 2019-12-16T07:15:58.837Z admin-forceRcUpdate at Module.load (internal/modules/cjs/loader.js:600:32) admin-forceRcUpdate
A 2019-12-16T07:15:58.837Z admin-forceRcUpdate at Object.Module._extensions…js (internal/modules/cjs/loader.js:712:10) admin-forceRcUpdate
A 2019-12-16T07:15:58.837Z admin-forceRcUpdate at Module._compile (internal/modules/cjs/loader.js:701:30) admin-forceRcUpdate
A 2019-12-16T07:15:58.837Z admin-forceRcUpdate at Object.<anonymous> (/srv/functions/src/index.ts:12:11) admin-forceRcUpdate
A 2019-12-16T07:15:58.837Z admin-forceRcUpdate Detailed stack trace: Error: Missing FIREBASE_CONFIG admin-forceRcUpdate
A 2019-12-16T07:15:58.837Z admin-forceRcUpdate Is there a syntax error in your code? admin-forceRcUpdate
A 2019-12-16T07:15:58.837Z admin-forceRcUpdate Provided module can’t be loaded. admin-forceRcUpdate

Removing access to process.env.FIREBASE_CONFIG fixes the issue. Local emulator works well with it

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
joehancommented, Dec 20, 2019

@stari4ek To import a module just for its side effects, use this syntax: import 'firebase-functions'; https://www.typescriptlang.org/docs/handbook/modules.html#import-a-module-for-side-effects-only

1reaction
stari4ekcommented, Dec 21, 2019

did check with import 'firebase-functions'; works well.

I’m not sure if this is good practice in ts/js, but, honestly speaking, for me it looks more like implementation-specific stuff leaking outside the module during it’s import.

This issue could be closed. Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

environment variable not working in react firebase config file
I am making a react app with firebase and I want to use environment variables for the firebase config. this is ...
Read more >
Configure your environment | Cloud Functions for Firebase
To store environment data, you can use the firebase functions:config:set command in the Firebase CLI. Each key can be namespaced using periods to...
Read more >
GCLOUD_PROJECT environment variable missing from ...
FIREBASE_CONFIG not set when Node.js 10 function deployed #433 ... GCLOUD_PROJECT env var no longer being populated in the Node 10 runtime.
Read more >
4.3.0.6 - Adding Firebase to React
Environment variables can only be set up for strings, not objects. ... import 'firebase/firestore'; const firebaseConfig = { apiKey: process.env.
Read more >
env firebase API key returns undifined
Some reason I can`t access the env variables in firebase-config. meh .env (in root folder / ) REACT_APP_API_KEY = asdheyhohellothankyou1 ...
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