File tree 1 file changed +13
-11
lines changed
1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change 4
4
"context"
5
5
"errors"
6
6
"fmt"
7
+ "io"
7
8
"log/slog"
8
9
"sync"
9
10
"sync/atomic"
@@ -258,6 +259,9 @@ func (r *streamReader) Read(p []byte) (int, error) {
258
259
if err != nil {
259
260
return 0 , err
260
261
}
262
+ if len (msg .Data ) == 0 {
263
+ return 0 , io .EOF
264
+ }
261
265
n := copy (p , msg .Data )
262
266
r .buf = msg .Data [n :]
263
267
return n , nil
@@ -270,18 +274,16 @@ func (r *streamReader) ReadByte() (byte, error) {
270
274
r .buf = r .buf [1 :]
271
275
return b , nil
272
276
}
273
- for {
274
- slog .Debug ("receiving next byte chunk" )
275
- msg , err := r .sub .NextMsgWithContext (r .ctx )
276
- if err != nil {
277
- return 0 , err
278
- }
279
- if len (msg .Data ) == 0 {
280
- continue
281
- }
282
- r .buf = msg .Data [1 :]
283
- return msg .Data [0 ], nil
277
+ slog .Debug ("receiving next byte chunk" )
278
+ msg , err := r .sub .NextMsgWithContext (r .ctx )
279
+ if err != nil {
280
+ return 0 , err
281
+ }
282
+ if len (msg .Data ) == 0 {
283
+ return 0 , io .EOF
284
284
}
285
+ r .buf = msg .Data [1 :]
286
+ return msg .Data [0 ], nil
285
287
}
286
288
287
289
func (r * streamReader ) Close () (err error ) {
You can’t perform that action at this time.
0 commit comments