firebase / firebase/firebase-tools

Authentication function not triggered in emulator behind a proxy

Open
#4,637 0 comments 3 reactions 0 assignees View on GitHub
type: bug
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

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 "\n\n\n\nERROR: The requested URL could not be retrieved
[...]
id=\"footer\">\n

Generated Thu, 09 Jun 2022 14:29:26 GMT by Proxy (squid/4.13)

\n\n\n\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 "\n\n\n\nERROR: The requested URL could not be retrieved
[...]
⚠ 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 #4386

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.