Skip to content

feat: harden the Redis connection for distributed runs - #24

Merged
beagleknight merged 1 commit into
mainfrom
feat/redis-resilience-fallback
Jul 16, 2026
Merged

feat: harden the Redis connection for distributed runs#24
beagleknight merged 1 commit into
mainfrom
feat/redis-resilience-fallback

Conversation

@beagleknight

@beagleknight beagleknight commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Why

Spec shards in factorialco/factorial CI intermittently fail with [specbandit] Redis error: ... even though the Redis server is healthy — it's a network-path problem. SpecBandit's shared Redis lives in one datacenter (Kilo location hel), and ~1/3 of runners now sit in another DC (fsn1) reaching it over an inter-DC WireGuard tunnel (~29 ms vs ~5 ms intra-DC). A transient blip exhausts SpecBandit's short retry budget and the CLI exits non-zero, reddening the build.

Mirrors the same change in the Ruby gem (factorialco/specbandit); the two implementations are used together in CI (push = JS, work = Ruby gem) and share the same RedisQueue / retry shape.

What

Harden the Redis connection so short blips are ridden out instead of failing the run:

  • Explicit client resilience (redisQueue.ts): new Redis(url, …) now sets connectTimeout, commandTimeout, and a bounded retryStrategy instead of relying on defaults.
  • Configurable retry budget (configuration.ts, redisQueue.ts): MAX_RETRIES default 3 → 5, env/flag-driven (SPECBANDIT_REDIS_MAX_ATTEMPTS / --redis-max-attempts), with capped (10s) exponential backoff.

No behavioural change when Redis is reachable; on a hard outage the CLI still exits non-zero as before.

Notes for review

  • Version bumped to 1.1.0 — adjust if it conflicts with your release flow.
  • Pre-existing local test note: jestAdapter/cypressAdapter "not installed" assertions fail locally because those peer deps are installed in the dev node_modules — unrelated to this change (verified on the untouched tree).

Tests

typecheck clean; suites pass (redisQueue, worker, configuration, publisher, cliAdapter, e2e-key-failed). Added connection-option, env-config (seconds → ms), and configurable-retry (incl. custom maxAttempts) coverage.

Draft for review.

SpecBandit's Redis is a best-effort coordinator for a distributed run, but CI
runners can sit a WAN hop away from it (e.g. a cross-datacenter Kilo mesh). A
transient blip was reddening spec shards with `[specbandit] Redis error: ...`
even though the Redis server was healthy — the connect just timed out over the
inter-DC tunnel. Mirrors the same change in the Ruby gem.

- Explicit client resilience: give ioredis connectTimeout, commandTimeout and a
  bounded retryStrategy instead of relying on defaults.
- Larger, configurable retry budget: MAX_RETRIES default raised 3 -> 5 and made
  env/flag-driven (SPECBANDIT_REDIS_MAX_ATTEMPTS / --redis-max-attempts), with
  capped (10s) exponential backoff so short blips are ridden out.

Bumps the package to 1.1.0.
@beagleknight
beagleknight force-pushed the feat/redis-resilience-fallback branch from 4e98fce to f673ed7 Compare July 16, 2026 11:21
@beagleknight beagleknight changed the title feat: Redis resilience + graceful degradation in work feat: harden the Redis connection for distributed runs Jul 16, 2026
@beagleknight
beagleknight marked this pull request as ready for review July 16, 2026 12:34
@beagleknight
beagleknight merged commit 162283a into main Jul 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants