Skip to content

Commit cf1a6a5

Browse files
fix: flush stream response when done event is sent (#172)
1 parent 09e13cb commit cf1a6a5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/ssestream/streaming.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,13 @@ func (s *Stream[T]) Next() bool {
138138

139139
for s.decoder.Next() {
140140
if s.done {
141-
return false
141+
continue
142142
}
143143

144144
if bytes.HasPrefix(s.decoder.Event().Data, []byte("[DONE]")) {
145+
// In this case we don't break because we still want to iterate through the full stream.
145146
s.done = true
146-
return false
147+
continue
147148
}
148149

149150
ep := gjson.GetBytes(s.decoder.Event().Data, "error")

0 commit comments

Comments
 (0)