← Back to Pull requests

fix(client): apply the command timeout and abortSignal to queued MULTI and pipelines #3515

Closed
unknown closed this pull request without merging on Oct 20, 2026 11:28 UTC
View on GitHub
unknown unknown commented on Oct 17, 2026 02:59 UTC
Author

Description

First of the two PRs for #3504, built on #3506 and #3507.

multi().exec() and execAsPipeline() ignored timeout and abortSignal, so a batch queued during a reconnect waited past the timeout. Now RedisCommandsQueue.addBatch gives the first command one timer and one abort listener for the whole batch, from the client options or withCommandOptions() / withAbortSignal(). If either fires before the first write, the whole batch is rejected (once written, it runs to the end) and a transaction keeps its WATCH state. The design's write-time WATCH recheck is not here: a watched batch queued when the socket drops acts as on master.

Behavior change for the release notes: with the 5 s default, a batch wholly queued for 5 s, say during a reconnect, now rejects with TimeoutError instead of resolving later. timeout: 0 or undefined opts out. Cluster, sentinel and pool batches use the node client's options until the second PR.

Benchmark from #3504
10,000 PINGs per batch, median ms of 9 runs (5 warmups + 9 samples each), Node 24.21.0, Redis 8.4.0
                 pipeline 0   pipeline 5000   MULTI 0   MULTI 5000
master f6e267f      12.6           12.1          13.5        12.6
this branch         12.3           12.3          13.6        14.1

master ignores the timeout, so its two MULTI columns run the same code (noise is about 1 ms)
12 more alternating MULTI 5000 runs, mean: master 14.1, this branch 14.0

benchmark/lib/batch-ping, 100 PINGs per batch, batches/s, median of 3 runs
                 MULTI    MULTI timeout 0   pipeline   pipeline timeout 0
master            9480         9463           10096          9567
this branch       9874        10161            9967         10125

New tests in both spec files next to the code.

---

Checklist

  • Does npm test pass with this change (including linting)?

  • Is the new or changed code fully tested?

  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Assisted by Claude/Codex.

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Medium Risk

    Changes core command-queue behavior for all MULTI/pipeline batches, including a release-note behavior change when the default 5s timeout applies to long-queued batches; WATCH/transaction edge cases are explicitly handled but warrant careful review.

    > Overview

    multi().exec() and execAsPipeline() now honor commandOptions.timeout and abortSignal for the whole batch, fixing cases where batches queued during reconnect never timed out (#3504).

    > The client routes transactions and pipelines through new RedisCommandsQueue.addBatch, which arms a single timer and abort listener on the batch head. If either fires before the first command is written, every command in the batch is dropped from the queue and rejected together; after writing starts, the batch runs to completion. Maintenance timeouts, queue moves, and chains already started (e.g. ASKING ahead of MULTI) follow the same rules without splitting in-flight work.

    > WATCH is preserved when a queued MULTI is cancelled before anything hits the wire (onCancel); docs add a Transactions and pipelines section describing the behavior. A batch-ping benchmark compares MULTI / pipeline with default vs timeout: 0.

    > <sup>Reviewed by Cursor Bugbot for commit 1df7d87bc33369d33b2c66a7cacd0af950cefc18. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 452 lines (+339 / -113) across 5 files Reviewer: Arthur031221 Review duration: 4829m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.45) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 452 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.366
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3515"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.4% (MEDIUM) · Higher = larger blast radius
    45.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.7% · Safe to merge
    19.7%