Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realtime Database Emulator Missing Connection Related Headers #3329

Closed
nate-trojian opened this issue May 3, 2021 · 3 comments · Fixed by #4500
Closed

Realtime Database Emulator Missing Connection Related Headers #3329

nate-trojian opened this issue May 3, 2021 · 3 comments · Fixed by #4500

Comments

@nate-trojian
Copy link

[REQUIRED] Environment info

firebase-tools:9.10.0

Platform:macOS

[REQUIRED] Test case

Streaming through the REST API for a Realtime Database location from the Realtime Database Emulator is missing either a Content-Length, Transfer-Encoding, or Connection Header to tell the client when a connection is completed.

When making a cURL request with verbose mode on to the Realtime Database Emulator
curl -v -X POST -H "Accept: text/event-stream" http://0.0.0.0/test.json
We receive Response Headers like

< HTTP/1.1 200 OK
< Content-Type: text/event-stream; charset=utf-8
< Cache-Control: no-cache
< Access-Control-Allow-Origin: *
< X-Firebase-Uuid: XXXXXX
< X-Firebase-Project-Id: XXXXX
< X-Firebase-Project-Number: 123456789
* no chunk, no close, no size. Assume close to signal end

Specifically we are given the warning * no chunk, no close, no size. Assume close to signal end

When making a similar cURL request with verbose mode on to a live Realtime Database project, we receive Response Headers like

< HTTP/1.1 200 OK
< Server: nginx
< Content-Type: text/event-stream; charset=utf-8
< Connection: close
< Cache-Control: no-cache
< Access-Control-Allow-Origin: *
< Strict-Transport-Security: max-age=31556926; includeSubDomains; preload

See here that we do not receive this warning due to the inclusion of the < Connection: close header.

While the cURL response will return data and new events properly, not all HTTP clients make the same assumption that cURL is explicitly stating it is making. Other HTTP client implementations expect stricter adherence to the HTTP/1.1 protocol. When none of these headers appear, they assume that transmission is still ongoing and therefore only partially complete when in fact all the data had been sent by the server.

[REQUIRED] Steps to reproduce

  1. Start the Realtime Database Emulator
  2. Create a new entry at any path
  3. From the CLI of your choosing, execute a Streaming HTTP request like curl -v -X POST -H "Accept: text/event-stream" http://0.0.0.0/<path_to_entry>.json
  4. Capture response headers

[REQUIRED] Expected behavior

Expected behavior is to match production behavior and include Connection: close header in Streaming REST API response.

[REQUIRED] Actual behavior

No Connection: close header appears in the response.

@WolfgangSenff
Copy link

This is actually a pretty big issue for us on the GodotNuts team, as it requires we put in a pretty big hack to do an unfortunate back-reference to Firebase in our server-sent-events implementation, which otherwise has no reference to Firebase. It would be really helpful to us if this could get prioritized and fixed.

@joehan
Copy link
Contributor

joehan commented Apr 25, 2022

@yuchenshi could you take a look at this and triage it to the right team?

@fredzqm fredzqm assigned fredzqm and unassigned yuchenshi Apr 27, 2022
@fredzqm
Copy link
Contributor

fredzqm commented Apr 27, 2022

Will take a look soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants