mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-06-13 15:47:38 +08:00
fix(SSE): capture Writer before goroutine, use select for channel send
Address PR review feedback: - Capture w := c.Writer before goroutine start, use w (not c.Writer) inside the goroutine to avoid holding *Context reference - Move channel send into select alongside context cancellation in all examples and tests, preventing goroutine leak when client disconnects while blocked on unbuffered send
This commit is contained in:
parent
2f94763c65
commit
559aefeb85
3 changed files with 16 additions and 17 deletions
|
|
@ -68,8 +68,7 @@ func TestEventStreamChanUnblocksOnClientDisconnect(t *testing.T) {
|
|||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
eventChan <- Event{Data: "tick"}
|
||||
case eventChan <- Event{Data: "tick"}:
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue