Skip to content

Commit ed875fb

Browse files
authored
feat(enhancement): change retry duration from seconds to milliseconds in SSE (#1010)
Change the retry duration from seconds to milliseconds for proper handling of client-specified retry intervals. This ensures compatibility with standard SSE behavior and prevents potential timeout issues. - https://html.spec.whatwg.org/multipage/server-sent-events.html#concept-event-stream-reconnection-time - https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#retry
1 parent 14d42b9 commit ed875fb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sse.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ func (es *EventSource) listenStream(res *http.Response) error {
558558
if len(ed.Retry) > 0 {
559559
if retry, err := strconv.Atoi(string(ed.Retry)); err == nil {
560560
es.lock.Lock()
561-
es.serverSentRetry = time.Second * time.Duration(retry)
561+
es.serverSentRetry = time.Millisecond * time.Duration(retry)
562562
es.lock.Unlock()
563563
} else {
564564
es.triggerOnError(err)

0 commit comments

Comments
 (0)