Skip to content

fix(redis): log the ready-wait outcome when a caller is refused - #63

Open
polylane[bot] wants to merge 1 commit into
polylane/autofix/hzqaqasosy02from
polylane/autofix/sux1pmki2fj1
Open

polylane[bot] wants to merge 1 commit into
polylane/autofix/hzqaqasosy02from
polylane/autofix/sux1pmki2fj1

Conversation

@polylane

@polylane polylane Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Generated by Polylane Autofix from the review of #60.

When Redis is configured but not ready, abuse-bounding callers wait briefly for the in-flight connection and then fail closed. Nothing recorded that wait's outcome, so an outage and a slow cold start looked the same in the logs. The refusal now emits one warning carrying how long the connection had been pending, whether the wait bound expired, and whether the instance had ever connected.

flowchart LR
  Caller["MCP rate limit or link probe budget"] --> Ready["getReadyRedisClient with caller"]
  Ready -->|"client ready"| Use["use client"]
  Ready -->|"not ready and Redis configured"| Wait["wait for connect up to 1s"]
  Wait --> Recheck{"ready after wait?"}
  Recheck -->|"yes"| Use
  Recheck -->|"no"| Warn["log warning: caller, hasRedisConnected, waitTimedOut, waitDurationMs"]
  Warn --> Closed["caller fails closed"]
Loading

Why this fix

The MCP rate limiter and the link-probe budget both fail closed when Redis is configured but unreachable, after waiting up to a second for the in-flight connect. That wait left no trace: the only warning on this path fires once per episode and carries no fields, so during an incident an operator could not tell a cold start that outran the bound from an instance that never connected.

The refusal now emits one warning that records waitTimedOut, waitDurationMs, hasRedisConnected, and the caller it hit — the MCP bucket name, or the probe batch size. Those fields answer, from the log alone, whether the connect completed but the socket was not ready (a real outage) or was still pending when the bound expired (a cold start that is too slow), and they size the blast radius: one user's write bucket versus a probe batch of twelve. The warning fires once per outage episode, matching the existing once-per-episode warning, so a sustained outage is not amplified into one line per request.

The caller descriptor is a small typed union, so a future caller cannot wait on readiness without declaring which surface it is.

4 files changed (+181/-22)
  • lib/collections/link-reachability.ts: modified, +4/-1
  • lib/common/redis.test.ts: modified, +108/-3
  • lib/common/redis.ts: modified, +65/-17
  • lib/integrations/mcp/rate-limit.ts: modified, +4/-1

View thread View autofix


Generated by Polylane. You can ask follow-ups by mentioning @polylane in a comment.

Co-authored-by: polylane[bot] <277585245+polylane[bot]@users.noreply.github.com>
@polylane polylane Bot added polylane severity:low Polylane autofix severity: low labels Sep 19, 2026
@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 76edbf03-49a3-4986-9b6d-94377352fe6a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cache-app Ready Ready Preview Sep 19, 2026 12:21pm UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

polylane severity:low Polylane autofix severity: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant