[REQUIRED] Environment info
firebase-tools:13.2.1
Platform:macOS
[REQUIRED] Test case
I recently updated a number of firebase dependencies on my library and noticed that hitting the emulator's Firebase functions took a long time and would often time out and be left with an internal error.
I realized that if I turned my wifi/internet connection off that they would run quickly again. I kept noticing the following line:
⚠ External network resource requested!
- URL: "http://169.254.169.254/computeMetadata/v1/universe/universe_domain"
This is followed by the function timing out:
i Your function timed out after ~60s. To configure this timeout, see
https://firebase.google.com/docs/functions/manage-functions#set_timeout_and_memory_allocation.
i Request to function failed: Error: socket hang up
I dug around and found out that this request was being made through gcp-metadata and timing out since it can't reach the specified IP which I'm guessing is an internal IP to Google Cloud.
I run the emulators in a Docker container and think that the environment is triggering some part of gcp-metadata or the firebase emulators to believe it is running on a Google Cloud instance and is timing out. I didn't notice this behavior while on firebase-tools version 11.17.0.
I checked the versions of gcp-metadata:
For now as a work around I am using the environment variable GCE_METADATA_HOST to set the host to 0.0.0.0 for the docker container so that the request fails immediately.
⚠ External network resource requested!
- URL: "http://0.0.0.0/computeMetadata/v1/universe/universe_domain"
- Be careful, this may be a production service.
In the newer versions of gcp-metadata (^5.3.0) I'd be able to use METADATA_SERVER_DETECTION=none.
[REQUIRED] Steps to reproduce
You can run the project at https://github.com/dereekb/dbx-components on version v10.0.17 (version v10.0.18 will have the workaround added to the Dockerfile). Run both the server ./serve-server.sh and web client ./serve-web.sh and go to http://localhost:9010/demo/app/profile/view. Change the profile info to kick off a firebase functions request.
[REQUIRED] Expected behavior
Emulator functions should not attempt to connect to or time out while trying to reach "http://169.254.169.254/computeMetadata/v1/universe/universe_domain".
[REQUIRED] Actual behavior
The first emulator function invocation attempts to reach 169.254.169.254 and times out after 60 seconds, causing the initial invocation to return an internal error.
[REQUIRED] Environment info
firebase-tools:13.2.1
Platform:macOS
[REQUIRED] Test case
I recently updated a number of firebase dependencies on my library and noticed that hitting the emulator's Firebase functions took a long time and would often time out and be left with an internal error.
I realized that if I turned my wifi/internet connection off that they would run quickly again. I kept noticing the following line:
This is followed by the function timing out:
I dug around and found out that this request was being made through gcp-metadata and timing out since it can't reach the specified IP which I'm guessing is an internal IP to Google Cloud.
I run the emulators in a Docker container and think that the environment is triggering some part of gcp-metadata or the firebase emulators to believe it is running on a Google Cloud instance and is timing out. I didn't notice this behavior while on firebase-tools version
11.17.0.I checked the versions of gcp-metadata:
For now as a work around I am using the environment variable
GCE_METADATA_HOSTto set the host to 0.0.0.0 for the docker container so that the request fails immediately.In the newer versions of gcp-metadata (^5.3.0) I'd be able to use
METADATA_SERVER_DETECTION=none.[REQUIRED] Steps to reproduce
You can run the project at https://github.com/dereekb/dbx-components on version v10.0.17 (version v10.0.18 will have the workaround added to the Dockerfile). Run both the server
./serve-server.shand web client./serve-web.shand go tohttp://localhost:9010/demo/app/profile/view. Change the profile info to kick off a firebase functions request.[REQUIRED] Expected behavior
Emulator functions should not attempt to connect to or time out while trying to reach "http://169.254.169.254/computeMetadata/v1/universe/universe_domain".
[REQUIRED] Actual behavior
The first emulator function invocation attempts to reach 169.254.169.254 and times out after 60 seconds, causing the initial invocation to return an internal error.