# Bug in tester: \`list\_blpop\`

**URL:** <https://forum.codecrafters.io/t/bug-in-tester-list-blpop/13315>\
**Category:** Challenges\
**Tags:** challenge:redis\
**Created:** [July 10, 2025, 4:05pm UTC](https://forum.codecrafters.io/t/bug-in-tester-list-blpop/13315 "2025-07-10T16:05:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![EshaanAgg](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/eshaanagg/32/399_2.png) [@EshaanAgg](https://forum.codecrafters.io/u/EshaanAgg)\
**Post date:** [July 10, 2025, 4:05pm UTC](https://forum.codecrafters.io/t/bug-in-tester-list-blpop/13315/1 "2025-07-10T16:05:55Z")

</div>

I do realise the challenge is unreleased, but I had been tinkering with it locally, so I thought it would be best to share my findings! Apologies if the same feels premature.

The current `BlockingClientGroupTestCase` just runs the assertion as is. without waiting, which is troublesome for custom implementations, as when the server is supposed to unblock a command/client, it may take a small amount of time to synchronize and do that. If, in that time itself, this assertion is run, then we get the `no content to read` error, and the whole test fails.

For example, consider the test `510`:  
Here are the logs from an unlucky run:

```auto
[stage-510] Running tests for Stage #510: BLPOP-1
[stage-510] $ ./your_program.sh
[your_program] Server started at port: 6379
[your_program] [Handshake] Master role with replID: 9d075485237c4f20908e83e0a352fc41 and replOffset: 0
[your_program] [Handshake] Completed successfully
[your_program] [:33364] Accepted connection
[stage-510] client-2: $ redis-cli BLPOP banana 0
[stage-510] client-2: Sent bytes: "*3\r\n$5\r\nBLPOP\r\n$6\r\nbanana\r\n$1\r\n0\r\n"
[stage-510] client-3: $ redis-cli BLPOP banana 0
[stage-510] client-3: Sent bytes: "*3\r\n$5\r\nBLPOP\r\n$6\r\nbanana\r\n$1\r\n0\r\n"
[stage-510] client-1: $ redis-cli RPUSH banana pineapple
[stage-510] client-1: Sent bytes: "*3\r\n$5\r\nRPUSH\r\n$6\r\nbanana\r\n$9\r\npineapple\r\n"
[your_program] [:33372] Accepted connection
[your_program] [:33378] Accepted connection
[your_program] [C :33378] [735339 ms] (BLPOP, banana, 0)
[your_program] [C :33372] [735339 ms] (BLPOP, banana, 0)
[your_program] [C :33364] [735345 ms] (RPUSH, banana, pineapple)
[your_program] [C :33364] [735345 ms] Response: Int(1)
[stage-510] client-1: Received bytes: ":1\r\n"
[stage-510] client-1: Received RESP integer: 1
[stage-510] Received 1
[your_program] [C :33378] [735339 ms] Response: Arr(Bulk('banana'), Bulk('pineapple'))
[stage-510] Received: "" (no content received)
[stage-510] ^ error
[stage-510] Error: Expected start of a new RESP2 value (either +, -, :, $ or *)
[stage-510] Test failed
[stage-510] Terminating program
[your_program] [C :33378] Unexpected error: Connection reset
[your_program] [C :33364] Connection closed

```

As you can see here:

- My sample implementation does respond to the `RPUSH` command correctly
- But before my server is able to sync the list and unblock the client that issued the `BLPOP` command, the tester runs the `BlockingClientGroupTestCase`’s assertion, and thus it reads no value, and the whole thing fails.
- On lucky runs, the same runs after my server is able to sync and send the value, and thus it passes.

The tester should actually fix this either by:

- Retrying the assertion if the received values are empty (a couple of times)
- Define a maximum time that the tester would allow the solutions to sync, and only run the assertions after it.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [July 10, 2025, 5:57pm UTC](https://forum.codecrafters.io/t/bug-in-tester-list-blpop/13315/4 "2025-07-10T17:57:29Z")

</div>

Hey @EshaanAgg, thanks for testing the Lists extension out!

We’ll take a closer look before releasing it. cc: @UdeshyaDhungana

---

<div class="post-metadata">

**Author:** ![rohitpaulk](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/rohitpaulk/32/6_2.png) [@rohitpaulk](https://forum.codecrafters.io/u/rohitpaulk)\
**Post date:** [July 11, 2025, 4:13am UTC](https://forum.codecrafters.io/t/bug-in-tester-list-blpop/13315/5 "2025-07-11T04:13:39Z")

</div>

@EshaanAgg mind sharing your code here please? We did account for the delay, it works the same way it does for all other stages - we wait upto 2 seconds whenever we try to read a RESP value: [redis-tester/internal/resp/connection/connection.go at 4ca1c5368a45d0181a1462cdb9fe82728776fb4d · codecrafters-io/redis-tester · GitHub](https://github.com/codecrafters-io/redis-tester/blob/4ca1c5368a45d0181a1462cdb9fe82728776fb4d/internal/resp/connection/connection.go#L171).

We can try running this against your code and help figure out what’s wrong – whether it’s a tester fault or a code error.

---

<div class="post-metadata">

**Author:** ![EshaanAgg](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/eshaanagg/32/399_2.png) [@EshaanAgg](https://forum.codecrafters.io/u/EshaanAgg)\
**Post date:** [July 11, 2025, 4:58am UTC](https://forum.codecrafters.io/t/bug-in-tester-list-blpop/13315/6 "2025-07-11T04:58:19Z")

</div>

Sure: you can find the same [here](https://github.com/EshaanAgg/redis-scala).

It might as well be a code fault, but while running the appropriate test, I saw the test failing almost instantaneously, without actually being blocked (for 2 seconds as you pointed out). Let me know if there’s anything I could help with in debugging!

---

<div class="post-metadata">

**Author:** ![UdeshyaDhungana](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/udeshyadhungana/32/3328_2.png) [@UdeshyaDhungana](https://forum.codecrafters.io/u/UdeshyaDhungana)\
**Post date:** [July 11, 2025, 10:03am UTC](https://forum.codecrafters.io/t/bug-in-tester-list-blpop/13315/7 "2025-07-11T10:03:10Z")

</div>

Hi @EshaanAgg , upon running the code sample provided and checking messages in Wireshark, we found that the server responds to an unexpecting client. For eg,

1. Client 1 issues BLPOP first

2. Client 2 issues BLPOP

3. Client 3 runs RPUSH

It is expected according to the Redis protocol that the longest waiting client should be served first. Ref: [Redis Docs](https://redis.io/docs/latest/commands/blpop/#what-key-is-served-first-what-client-what-element-priority-ordering-details).

 ![Screenshot 2025-07-11 at 14.53.50](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/0/01adffec4dde300dbb8d718e204271dd736460fd.png)  
 ![Screenshot 2025-07-11 at 14.53.58](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/b/bee9e24f9e3406716090a59783e198b9a13aa08c.png)  
 ![Screenshot 2025-07-11 at 14.54.06](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/4/4e755ea3d7c3b334fc14f7c499d0c9ad8d8c078f.png)

Here, since the client in port 61783 issues `BLPOP` first, the tester expects the response from that client. The RESP array is received in 61784 instead.

Meanwhile, we will be improving the tester before release.

Please let me know if you have any queries.

---

<div class="post-metadata">

**Author:** ![EshaanAgg](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/eshaanagg/32/399_2.png) [@EshaanAgg](https://forum.codecrafters.io/u/EshaanAgg)\
**Post date:** [July 11, 2025, 1:27pm UTC](https://forum.codecrafters.io/t/bug-in-tester-list-blpop/13315/8 "2025-07-11T13:27:38Z")

</div>

Ahh! That’s a sneaky bug! Didn’t realise the error was that the server was sending the same to the wrong client. Thanks so much for the debugging help 🙂

Adding more testcases to catch flaky implementations like mine, or having logs if the wrong client receives the message indeed, would be great additions to the tester! Thanks again 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [July 20, 2025, 12:15am UTC](https://forum.codecrafters.io/t/bug-in-tester-list-blpop/13315/10 "2025-07-20T00:15:32Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
