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

OnConnect can be delayed #149

Open
pjcdawkins opened this issue Feb 8, 2023 · 0 comments · May be fixed by #151
Open

OnConnect can be delayed #149

pjcdawkins opened this issue Feb 8, 2023 · 0 comments · May be fixed by #151

Comments

@pjcdawkins
Copy link

pjcdawkins commented Feb 8, 2023

The OnConnect callback (added in #137) is only sent during the readLoop so it will only be triggered after the server sends an event, which could be some time (or even never) after a connection is established:

sse/client.go

Line 231 in c6d5381

c.connectedcb(c)

It seems the callback could and should be called here instead, directly after the HTTP response:

sse/client.go

Lines 98 to 100 in c6d5381

defer resp.Body.Close()
reader := NewEventStreamReader(resp.Body, c.maxBufferSize)

sse/client.go

Lines 152 to 156 in c6d5381

if !connected {
// Notify connect
errch <- nil
connected = true
}

or, at the top of readLoop

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

Successfully merging a pull request may close this issue.

1 participant