@@ -4843,6 +4843,24 @@ var _ = Describe("Commands", func() {
48434843 Expect (err ).To (Equal (redis .Nil ))
48444844 })
48454845
4846+ Describe ("canceled context" , func () {
4847+ It ("should unblock XRead" , func () {
4848+ ctx2 , cancel := context .WithCancel (ctx )
4849+ errCh := make (chan error , 1 )
4850+ go func () {
4851+ errCh <- client .XRead (ctx2 , & redis.XReadArgs {
4852+ Streams : []string {"stream" , "$" },
4853+ }).Err ()
4854+ }()
4855+
4856+ var gotErr error
4857+ Consistently (errCh ).ShouldNot (Receive (& gotErr ), "Received %v" , gotErr )
4858+ cancel ()
4859+ Eventually (errCh ).Should (Receive (& gotErr ))
4860+ Expect (gotErr ).To (HaveOccurred ())
4861+ })
4862+ })
4863+
48464864 Describe ("group" , func () {
48474865 BeforeEach (func () {
48484866 err := client .XGroupCreate (ctx , "stream" , "group" , "0" ).Err ()
@@ -5023,6 +5041,26 @@ var _ = Describe("Commands", func() {
50235041 Expect (err ).NotTo (HaveOccurred ())
50245042 Expect (n ).To (Equal (int64 (2 )))
50255043 })
5044+
5045+ Describe ("canceled context" , func () {
5046+ It ("should unblock XReadGroup" , func () {
5047+ ctx2 , cancel := context .WithCancel (ctx )
5048+ errCh := make (chan error , 1 )
5049+ go func () {
5050+ errCh <- client .XReadGroup (ctx2 , & redis.XReadGroupArgs {
5051+ Group : "group" ,
5052+ Consumer : "consumer" ,
5053+ Streams : []string {"stream" , ">" },
5054+ }).Err ()
5055+ }()
5056+
5057+ var gotErr error
5058+ Consistently (errCh ).ShouldNot (Receive (& gotErr ), "Received %v" , gotErr )
5059+ cancel ()
5060+ Eventually (errCh ).Should (Receive (& gotErr ))
5061+ Expect (gotErr ).To (HaveOccurred ())
5062+ })
5063+ })
50265064 })
50275065
50285066 Describe ("xinfo" , func () {
0 commit comments