Skip to content

Event source returned unexpected content type '' #210

Closed

Description

@matt-dutchie

Describe the bug

Hello.

I'm attempting to update our code to use v7.0.2 of the ruby SDK. I'm receiving the following error when I try to boot up a client:

[2023-02-22T18:08:50] INFO  | [LDClient] Initializing stream connection
[2023-02-22T18:08:50] INFO  | Connecting to event stream at https://stream.launchdarkly.com/all
[2023-02-22T18:08:50] WARN  | Event source returned unexpected content type ''
...
# Times out, then retries ad nauseum

Tracing this bug backwards, I was able to reproduce starting in v6.0.0.

After doing a little code spelunking in the ld-eventsource plugin, I ran the following code to see if something weird is going on with the http request:

client = HTTP::Client.new()

sdk_key = # using our sdk key
headers = {
  "Accept"=>"text/event-stream",
  "Cache-Control"=>"no-cache",
  "User-Agent"=>"ruby-eventsource",
  "Authorization" => sdk_key
}

client.request("GET", "https://stream.launchdarkly.com/all", { headers: headers })

# => #<HTTP::Response/1.1 200 OK {"Date"=>"Thu, 23 Feb 2023 00:27:40 GMT", "Content-Type"=>"text/event-stream; charset=utf-8", "Transfer-Encoding"=>"chunked", "Connection"=>"close", "Accept-Ranges"=>"bytes", "Cache-Control"=>"no-cache, no-store, must-revalidate", "Etag"=>"\"9347c\"", "Ld-Region"=>"us-east-1", "Strict-Transport-Security"=>["max-age=31536000", "max-age=31536000"]}>

While not exactly analogous to your HTTP::Client usage within the ruby-eventsource plugin powering the connection, this seems to be at odds with the error case here: https://github.com/launchdarkly/ruby-eventsource/blob/68a3a91b70d13919a7b0fdcc5863483b3d52f802/lib/ld-eventsource/client.rb#L272

I'll keep digging but any help would be useful.

We are pegged to Faraday v1.10.0 and http v4.4.1 for dependency reasons.

Thank you.

Activity

  1. matt-dutchie commented on Feb 23, 2023

    @matt-dutchie
    ContributorAuthor

    After some more exploration, it appears that the issue is with this line in the ruby-eventsource library:

    https://github.com/launchdarkly/ruby-eventsource/blob/main/lib/ld-eventsource/client.rb#L271

    cxn.headers["content-type"] is evaluating to an empty string, while cxn.headers["Content-Type"] evaluates to the correct value (text/event-stream; charset=utf-8). Correcting this locally establishes the connection without issue.

  2. louis-launchdarkly commented on Mar 1, 2023

    @louis-launchdarkly
    Contributor

    Hello @matt-dutchie, thank you so much for the report and investigation. To clarify, the issue is that while the Ruby SDK can connect to LaunchDarkly's backend and get flag data, it keeps splitting out this warning in the logs because of the upper-lower cases mismatch that you identified - is that correct?

    Keeping track of this issue with 190660.

  3. matt-dutchie commented on Mar 2, 2023

    @matt-dutchie
    ContributorAuthor

    @louis-launchdarkly Yea, it works after tweaking the casing on the header access. I've opened a PR against the other lib here: launchdarkly/ruby-eventsource#36

  4. matt-dutchie commented on Mar 3, 2023

    @matt-dutchie
    ContributorAuthor

    Ah -- sorry, I misunderstood your comment. We were not able to connect without this change, the casing was causing an error not a warning and the initialization of the client was timing out.

  5. matt-dutchie commented on Mar 10, 2023

    @matt-dutchie
    ContributorAuthor

    This should be fixed by my PR against ruby-eventsource, closing!

  6. keelerm84 commented on Mar 10, 2023

    @keelerm84
    Member

    I will still need to cut a release for you for both the event source and the SDK before this is fully resolved. There are some internal blockers at the moment but I will work to get this done by early next week at the latest.

    Thanks again for your contribution!

  7. keelerm84 commented on Mar 17, 2023

    @keelerm84
    Member

    Sorry for the delay, but this has been fixed in 7.0.3

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions