Skip to content

Commit 35ce6cb

Browse files
authored
batchio: return Context error if cancelled with no data (#4)
1 parent e6eece4 commit 35ce6cb

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

batchio/batchio.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ func (r *Reader) Next(ctx context.Context) ([]byte, error) {
9898
return r.buf[:r.nread:r.nread], nil
9999
case <-ctx.Done():
100100
r.pendingRead = true
101+
if r.nread == 0 {
102+
return nil, ctx.Err()
103+
}
101104
return r.buf[:r.nread:r.nread], nil
102105
}
103106
}

0 commit comments

Comments
 (0)