You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: stream connections longer than 5 minutes are dropped (#244)
This fixes [streaming connection dropping after 5
minutes](#243).
The problem was applying a 5 minute timeout to an `async_read`
_operation_, when the actual intent was to apply it to the act of
receiving _any data_.
The timeout exists to prevent the client from hanging infinitely if the
server stops responding. LaunchDarkly sends heartbeats to clear the
timer.
With `async_read`, the operation won't complete until the response body
is finished. Since the body will never finish until the client shuts
down (or server interrupts it), it's not possible to institute a
timeout.
The solution is to use `async_read_some`, which completes whenever data
arrives.
This way, we can assign the 5 minute timeout as an upper bound on
receiving any data, as was originally intended.
-----
A side effect of this change was breaking the `reconnection` SSE
contract tests, which proved to be somewhat of a rabbithole.
The upshot is that we weren't handling chunked encoding properly when
chunked encoding _ends_. The original code assumes we either terminate
an async read with an error, or it goes on forever.
In fact it should perform the backoff algorithm if we detect the end of
chunked encoding.
0 commit comments