Skip to content

OnConnect can be delayed #149

Open
@pjcdawkins

Description

@pjcdawkins

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

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