Prevent timed-out offline commands from replaying#2131
Open
MicroMilo wants to merge 2 commits into
Open
Conversation
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit f248cbb. Configure here.
Contributor
|
@MicroMilo Thanks for the PR. I’ll take a look and review it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
This preserves the existing
commandTimeoutsemantics as a total command lifetime timeout, including time spent waiting in the offline queue, but prevents a command that has already timed out from being replayed later when the connection becomes ready.Fixes #2130.
Details
sendCommand()when the command is already settled, before queueing or writing it again.commandTimeoutoption docs to state that the timer starts when the command is issued and includes offline queue / reconnect wait.Tests
Note
Medium Risk
Touches core command lifecycle and send paths for standalone and cluster clients; behavior change is narrow (already-rejected commands) but affects reconnect/offline-queue replay semantics.
Overview
Fixes a case where a command that hit
commandTimeoutwhile sitting in the offline queue could still be sent to Redis after the connection became ready, even though the caller had already received "Command timed out".Commandnow tracksisSettledas a terminal state on reject/resolve (including timeout rejection), with guards so settled commands are not resolved/rejected again. Command and blocking timeout handlers useisSettledinstead ofisResolved.Redis.sendCommandandCluster.sendCommandreturn the existing promise immediately whencommand.isSettled, so flushed/replayed offline commands are not queued or written again.commandTimeoutdocs now state the timer starts when the command is issued and counts offline-queue wait. A functional test uses a delayed connector to assert the server receives no bytes after a timed-out offlineset.Reviewed by Cursor Bugbot for commit 034ebcc. Bugbot is set up for automated code reviews on this repo. Configure here.