FUNCTION_REGION removed for Node 10

405 views
Skip to first unread message

Cosmin Onea

unread,
Jan 19, 2020, 11:56:36 AM1/19/20
to Firebase Google Group
Does anyone know why FUNCTION_REGION is not available anymore?

I have a multi-region deployment of functions and to be able to get the right config for each region I need to know the region. 

How would one do that in Node 10?




Sam Stern

unread,
Jan 21, 2020, 12:35:47 PM1/21/20
to Firebase Google Group
Hey Cosmin,

As you noticed, the default environment variables depend on your Node version:
https://cloud.google.com/functions/docs/env-var#environment_variables_set_automatically


Something like:
gcloud functions deploy --region=us-central1 MyFunctionName --set-env-vars FUNCTION_REGION=us-central1

- Sam

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/f941c407-88b9-4e23-8e19-18c596294dc9%40googlegroups.com.

Cosmin Onea

unread,
Jan 21, 2020, 5:54:24 PM1/21/20
to fireba...@googlegroups.com
Hi Sam,

I did try that before reporting this but got an error and I assumed firebase functions have something special and can't be updated with the gcloud command.

The error at the command line looks like this:

Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.functions.deploy) OperationError: code=13, message=Error setting up the execution environment for your function. Please try deploying again after a few minutes.


The error in Stackdriver looks like this:

image.png

The functions keeps failing and eventually fails the deployment.

Cosmin.



Sam Stern

unread,
Jan 21, 2020, 6:38:13 PM1/21/20
to Firebase Google Group
Hmmm that's strange.  We just tried it over here and were able to get this to work.  Just to make sure we're on the same page, can you try:

1. Successfully deploy your function using the firebase CLI, without any special env vars.
2. Run gcloud functions deploy --region=us-central1 helloWorld --update-env-vars FUNCTION_REGION=us-central1 --runtime nodejs10 (change to match your real function name and region) 

Note that in (2) I am using --update-env-vars which I believe is a better option than my original suggestion of --set-env-vars.

- Sam

Cosmin Onea

unread,
Jan 21, 2020, 8:37:22 PM1/21/20
to fireba...@googlegroups.com
I generated the helloWorld example via the cli and added a couple of regions to it. After deployment, I tried to update-env-vars and it failed the same way as above.

It must be the multi-region that breaks it then. If you can't replicate it at your end let me know and I'll create a Github repo.

export const helloWorld = functions
.region('us-central1', 'europe-west2')
.https.onRequest((request, response) => {
response.json(process.env);
});

Sam Stern

unread,
Jan 22, 2020, 5:31:31 PM1/22/20
to Firebase Google Group
Hey Cosmin,

I was able to reproduce the same error you have with gcloud.  Let me file a bug internally and see if I can get some help figuring it out.

- Sam

Sam Stern

unread,
Mar 20, 2020, 11:06:47 AM3/20/20
to Firebase Google Group
I know it's been a while but I have an update here.  It seems like this is an error with "gcloud".  If I use the Google Cloud Console UI to set environment variables I am able to properly update FUNCTION_REGION.  Here are my successful test cases"
https://us-central1-fir-dumpster.cloudfunctions.net/helloWorld
https://europe-west2-fir-dumpster.cloudfunctions.net/helloWorld

The gcloud team is aware of this bug now and has it on their list.  Thanks again for reporting and hopefully this workaround (which I know is a pain) can be helpful until it's fixed.

- Sam
Reply all
Reply to author
Forward
0 new messages