Skip to content

Fix infinite loop when the connection closes partway through a bulk reply - #1731

Merged
tillkruss merged 5 commits into
predis:mainfrom
NotAFlightRisk:fix/bulk-reply-eof-loop
Oct 6, 2026
Merged

tillkruss merged 5 commits into
predis:mainfrom
NotAFlightRisk:fix/bulk-reply-eof-loop

Conversation

@NotAFlightRisk

Copy link
Copy Markdown
Contributor

fread() gives back an empty string at EOF rather than false, so when the connection closes partway through a bulk reply, predis keeps waiting for bytes it'll never recieve and pegs a core until you kill it. read_write_timeout doesn't help because every read returns straight away.

You don't need anything exotic to hit it. A pubsub subscriber that falls behind gets cut off by Redis's default client-output-buffer-limit pubsub 32mb 8mb 60, and when the cut lands in middle of a message the subscriber on 3.6.1 just spins. Killing Redis during a big GET does the same.

Both connection classes had the same loop, so both now throw the usual ConnectionException when a read comes back empty at EOF, same as a close between replies already does. The tests are most of the diff, the fix itself is a few lines in each class.

@tillkruss
tillkruss merged commit 0f3f616 into predis:main Oct 6, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants