Repository navigation
Authentication function not triggered in emulator behind a proxy #4637
Copy link
Copy link
Open
Labels
Description
Environment info
firebase-tools: 10.9.2
firebase-functions: 3.21.2
node: 16.14.2
OpenJDK: 11.0.14
Platform: Debian - Bullseye
Test case
Launch the emulator behind a proxy, set a no_proxy env variable, it doesn't matter, authentication calls seem to be sent to the proxy
Steps to reproduce
- set up a proxy server
- set the env vars http_proxy & https_proxy
- set the no_proxy var as "no_proxy=localhost"
- launch the emulator suite behind the proxy (in our case, a self hosted github runner with proxy env set)
- watch your proxy logs
- launch some unit tests to register a new user
- you should see the requests to authentication functions through your proxy
Expected behavior
All requests performed by the emulator should read the no_proxy variable
Actual behavior
Our proxy is restrictive and allows only a few requests, everything seems working but the authentication calls
Working request on firestore emulator
[2022-06-09T14:34:46.443Z] >>> HTTP REQUEST PUT http://localhost:8080/emulator/v1/projects/my-project/triggers/us-central1-onAccountCreation-0
{"eventTrigger":{"eventType":"providers/cloud.firestore/eventTypes/document.create","resource":"projects/my-project/databases/(default)/documents/accounts/{accountId}","service":"firestore.googleapis.com"}}
[2022-06-09T14:34:46.456Z] Jun 09, 2022 4:34:46 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
{"metadata":{"emulator":{"name":"firestore"},"message":"Jun 09, 2022 4:34:46 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-06-09T14:34:46.608Z] Jun 09, 2022 4:34:46 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected HTTP/2 connection.
{"metadata":{"emulator":{"name":"firestore"},"message":"Jun 09, 2022 4:34:46 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected HTTP/2 connection.\n"}}
[2022-06-09T14:34:47.363Z] <<< HTTP RESPONSE 200 {"content-type":"application/json","content-length":"4"}
✔ functions[us-central1-onAccountCreation]: firestore function initialized. {"metadata":{"emulator":{"name":"functions"},"message":"\u001b[1mfirestore\u001b[22m function initialized."}}
[2022-06-09T14:34:47.364Z] addFirestoreTrigger "{\"eventTrigger\":{\"eventType\":\"providers/cloud.firestore/eventTypes/document.create\",\"resource\":\"projects/my-project/databases/(default)/documents/emailEvents/{id}\",\"service\":\"firestore.googleapis.com\"}}"
Failing request on authentication functions
[2022-06-09T14:38:23.510Z] <<< [apiv2][status] POST http://localhost:5001/functions/projects/my-project/trigger_multicast 503
[2022-06-09T14:38:23.511Z] <<< [apiv2][body] POST http://localhost:5001/functions/projects/my-project/trigger_multicast "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"[http://www.w3.org/TR/html4/strict.dtd\](http://www.w3.org/TR/html4/strict.dtd/)">\n<html><head>\n<meta type=\"copyright\" content=\"Copyright (C) 1996-2020 The Squid Software Foundation and contributors\">\n<meta http-equiv=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n<title>ERROR: The requested URL could not be retrieved</title>
[...]
id=\"footer\">\n<p>Generated Thu, 09 Jun 2022 14:29:26 GMT by Proxy (squid/4.13)</p>\n<!-- ERR_CONNECT_FAIL -->\n</div>\n</body></html>\n"
⚠ functions: Firebase Authentication function was not triggered due to emulation error. Please file a bug. {"metadata":{"emulator":{"name":"auth"},"message":"Firebase Authentication function was not triggered due to emulation error. Please file a bug."}}
More context
- tried some proxy configurations
- no_proxy vs NO_PROXY
- no_proxy=localhost vs no_proxy=localhost:8080,localhost:5001,localhost:9099
- tried to downgrade firebase-tools@9.23.3
- less logs, still not working
- tried to upgrade firebase-tools@11.0.1
- works even worse
[2022-06-09T14:02:41.199Z] >>> [apiv2][body] PUT http://localhost:8080/emulator/v1/projects/my-project/triggers/us-central1-onAccountCreation-0 "{\"eventTrigger\":{\"eventType\":\"providers/cloud.firestore/eventTypes/document.create\",\"resource\":\"projects/my-project/databases/(default)/documents/accounts/{accountId}\",\"service\":\"firestore.googleapis.com\"}}"
[2022-06-09T14:02:41.209Z] <<< [apiv2][status] PUT http://localhost:8080/emulator/v1/projects/my-project/triggers/us-central1-onAccountCreation-0 503
[2022-06-09T14:02:41.209Z] <<< [apiv2][body] PUT http://localhost:8080/emulator/v1/projects/my-project/triggers/us-central1-onAccountCreation-0 "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"[http://www.w3.org/TR/html4/strict.dtd\](http://www.w3.org/TR/html4/strict.dtd/)">\n<html><head>\n<meta type=\"copyright\" content=\"Copyright (C) 1996-2020 The Squid Software Foundation and contributors\">\n<meta http-equiv=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\n<title>ERROR: The requested URL could not be retrieved</title>
[...]
⚠ Error adding firestore function: FirebaseError: Unable to parse JSON: SyntaxError: Unexpected token < in JSON at position 0 {"metadata":{"emulator":{"name":"functions"},"message":"Error adding firestore function: FirebaseError: Unable to parse JSON: SyntaxError: Unexpected token < in JSON at position 0"}}
- could be related to Auth function not triggered in emulator whenever http_proxy is set #4386
Reacted by Guillaume Acard, Amaury Billet and Mark
Activity