launchdarkly / swift-eventsource

Server-sent events (SSE) client implementation in Swift for iOS, macOS, tvOS, and watchOS
https://launchdarkly.github.io/swift-eventsource/
Other
187 stars 34 forks source link

Fix start() re-entrancy (#1) #56

Closed g-mark closed 1 year ago

g-mark commented 1 year ago

Fixes an EventSource.start() re-entrancy problem

When:

  1. EventSource.start() is called
  2. EventSource.start() is called again, before the network response from the first call has been received

Then:

The underlying issue is that start() is checking for readyState == .raw, but readyState isn't set until a network response has been received.

Requirements

Related issues

None

Describe the solution you've provided

Set readyState = .connecting in start(), immediately after checking for readyState == .raw.

Describe alternatives you've considered

None

Additional context

None

tanderson-ld commented 1 year ago

Hi there @g-mark , thank you for the contribution! I have it on my list to take a look at the changes and related code/behavior and if it looks good, we'll integrate the change.