Skip to content

feat: enforce per-use-case Redis read deadlines#83

Open
lan17 wants to merge 1 commit into
mainfrom
agent/redis-read-deadlines
Open

feat: enforce per-use-case Redis read deadlines#83
lan17 wants to merge 1 commit into
mainfrom
agent/redis-read-deadlines

Conversation

@lan17

@lan17 lan17 commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • require an application-selected RedisConfig.readTimeoutMs and support static CachedOptions.redisReadTimeoutMs overrides
  • enforce one monotonic core wait deadline around each shared semantic Redis read, with late-settlement consumption and a cooperative AbortSignal
  • represent operational read failures explicitly, fail open to the source, and skip the post-fallback Redis write
  • preserve safe local publication for untracked keys while suppressing tracked local publication when watermark safety was not established
  • pass read cancellation to node-redis, preserve GLIDE's client-level timeout contract, and export RedisReadContext plus RedisReadTimeoutError
  • document the v0.8 migration and extend packed-consumer, adapter, liveness, coalescing, publication, and performance coverage

Why

Redis fail-open behavior was rejection-driven, so a read promise that never settled retained the process flight and prevented the source fallback from starting. A rejected untracked read also proceeded to a Redis write after fallback, exposing one invocation to the unhealthy client twice. The core now bounds caller-visible read waiting while leaving underlying resource lifetime to finite client-native budgets.

Compatibility

This is a deliberate pre-1.0 configuration change: every Redis-enabled DialCache instance must now provide a positive finite readTimeoutMs. Custom one-argument DialCacheRedisClient.read(request) implementations remain structurally compatible because the new read context is optional.

Validation

  • corepack pnpm check — typecheck, 266 unit tests with coverage, ESM/CJS build and declarations, packed-consumer checks
  • corepack pnpm test:integration — 69 Redis 6.2, Valkey 8, and Redis Cluster cases
  • corepack pnpm benchmark:request-local — default 50,000-iteration / 1,000-follower matrix; Redis fan-out asserted one semantic read, one deadline timer, and one timer clear
  • corepack pnpm audit --prod --audit-level high — no known vulnerabilities
  • git diff --check

Closes #38

@lan17
lan17 marked this pull request as ready for review July 24, 2026 03:18
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.

Enforce per-use-case Redis read deadlines and fail open without a second Redis operation

1 participant