← Back to Pull requests

fix(ioredis): trace each command once when replayed from the offline queue #10931

Closed
unknown closed this pull request without merging on Nov 06, 2026 19:20 UTC
View on GitHub
unknown unknown commented on Oct 26, 2026 18:25 UTC
Author

What does this PR do?


Prevents duplicate redis.command spans when ioredis passes the same command through Redis.prototype.sendCommand more than once. The wrapper marks a command with a module-private symbol when it starts its span, and passes later calls for that command straight through.

Motivation


ioredis reuses the same Command object when it:
  • flushes the offline queue once the connection is ready (commands issued while connecting, including commands flushed from an auto pipeline when enableAutoPipelining is set),

  • resends unfulfilled commands after a reconnect (autoResendUnfulfilledCommands, on by default),

  • resends a failed command because reconnectOnError returned 2.
  • Each call started a new span, so one command sent over the wire was reported as two or more redis.command spans. Since every replay path reuses the object, a flag on the command covers all of them without tracking queues or wrapping connection state changes. ioredis 5.11 deduplicates its own native tracing the same way (command.isTraced); this uses a separate symbol so it doesn't interfere with that.

    Test evidence


  • Red, test-only commit 6ddd5a7fd: ioredis job. The "while connecting" test fails on every supported ioredis version with 2 !== 1.

  • The new reconnectOnError test fails on every supported ioredis version against the previous fix on this branch, with 3 !== 1.

  • Local Redis-backed run: PLUGINS=ioredis SPEC=index npm run test:plugins — 200 passing across installed ioredis versions 2–6. ESLint passes for both changed files.
  • Additional Notes


  • Regression tests assert exactly one span for offline auto-pipeline commands, ready-connection commands, a blocking command resent after a socket disconnect, and a command resent by reconnectOnError.
  • 🤖 Generated with Claude Code

    Diff: 243 lines (+182 / -61) across 3 files Reviewer: tlhunter Review duration: 15895m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 243 lines diff across 3 files
    0.39
    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%
    60%
    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.329
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #10931"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 38.8% (MEDIUM) · Higher = larger blast radius
    38.8%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 15.3% · Safe to merge
    15.3%