firebase / firebase-tools

The Firebase Command Line Tools
MIT License
3.97k stars 917 forks source link

Auth function not triggered in emulator whenever http_proxy is set #4386

Open lm1 opened 2 years ago

lm1 commented 2 years ago

On Windows whenever http_proxy env. variable is set, functions emulator displays the following message instead of user().onCreate() handler being triggered: ! functions: Firebase Authentication function was not triggered due to emulation error. Please file a bug.

It does not matter if http_proxy is pointing to a correct proxy server or set to a dummy value. Having no_proxy=localhost does not mitigate the issues either. Seems that logging from HTTP functions is also impaired in that case.

Issue reproduces whether user is created from client side auth emulator UI or from admin SDK. It was tested with a demo project.

[REQUIRED] Environment info

firebase-tools: 10.5.0 firebase-functions: 3.19.0 openjdk version: 11.0.8

Platform: Windows

google-oss-bot commented 2 years ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

yuchenshi commented 2 years ago

Would you mind try unsetting http_proxy in the command line / command prompt before running firebase emulators:start? The Auth and Functions emulator do communicate over HTTP, which may lead to the issue you've experienced.

lm1 commented 2 years ago

Yes I can work-around this issues in my specific case using emulators only locally, but I guess it may be somewhat more troublesome in configuration where emulated services reach production database(?) Note it fails even if no_proxy is set to localhost, and documentation does not say a word about proxy configuration. The error message is confusing, and actually contains a request to file a bug, so here it is. Perhaps it is worth improving the user experience here, as it took considerable amount of time to find out this error is related to proxy settings.

yuchenshi commented 2 years ago

That sounds very reasonable. Unfortunately, we don't have much control over proxy env var behaviors since it is inside the request library we use. I think a good starting point is for the CLI to print a warning when http_proxy etc. is set. We're open for Pull Requests.