Skip to content

Commit 525c0c0

Browse files
committed
etos-sse v1: use buffered receiver channel
Change-Id: Ie8bc3fc486aec1177d964e4d3208cae52906f629
1 parent a9c1adb commit 525c0c0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/sse/v1/sse.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ func (h SSEHandler) GetEvents(w http.ResponseWriter, r *http.Request, ps httprou
258258

259259
logger.Info("Client connected to SSE")
260260

261-
receiver := make(chan events.Event) // Channel is closed in Subscriber
261+
// Buffered channel prevents Subscribe goroutine from blocking when client disconnects.
262+
// The buffer allows Subscribe to send events without a receiver, allowing it to loop back and detect ctx.Done().
263+
receiver := make(chan events.Event, 100)
262264
go h.Subscribe(receiver, logger, r.Context(), last_id, identifier, url)
263265

264266
for {

0 commit comments

Comments
 (0)