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

Not all empty messages are actually ignored #163

Open
emmrk opened this issue May 23, 2023 · 0 comments
Open

Not all empty messages are actually ignored #163

emmrk opened this issue May 23, 2023 · 0 comments

Comments

@emmrk
Copy link

emmrk commented May 23, 2023

Description

Comments (the : message syntax) are supposed to be ignored by the client but this actually works only before an event with an ID is sent. After the first event that has an ID, all empty messages generate events on the client because the last ID is reloaded and then any message is "not empty" anymore.

How to reproduce

Server:

cat <<EOF | nc -l -p 9999
HTTP/1.1 200 OK
Content-Type: text/event-stream

: this comment does not generate an event

id: 0
data: sending some data with an ID

: this comment DOES generate an event

EOF

Client:

package main

import (
        "fmt"

        sse "github.com/r3labs/sse/v2"
)

func main() {
        client := sse.NewClient("http://localhost:9999")

        client.SubscribeRaw(func(msg *sse.Event) {
                fmt.Printf("got a message %+v (data: %s)\n", msg, msg.Data)
        })
}

Output:

$ go run .
got a message &{timestamp:{wall:0 ext:0 loc:<nil>} ID:[48] Data:[115 101 110 100 105 110 103 32 115 111 109 101 32 100 97 116 97 32 119 105 116 104 32 97 110 32 73 68] Event:[] Retry:[] Comment:[]} (data: sending some data with an ID)
got a message &{timestamp:{wall:0 ext:0 loc:<nil>} ID:[48] Data:[] Event:[] Retry:[] Comment:[]} (data: )

What should happen instead?

I'd say that empty messages should not generate events

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

No branches or pull requests

1 participant