fix(api): surface shared-store (Redis/Upstash) liveness in /health [BUG-111] - #226
fix(api): surface shared-store (Redis/Upstash) liveness in /health [BUG-111]#226Morenikeoa wants to merge 1 commit into
Conversation
…UG-111) When Upstash Redis becomes unreachable, UpstashStore silently falls back to per-replica in-memory enforcement for rate limits, WS connection caps, and auth bans — the only signal is a scattered logger.warn() per failed call. Operators had no way to see this degradation from /health. Add ping() to the SharedStore interface: InMemoryStore is trivially always healthy (it's the deliberately chosen backend), UpstashStore issues a real Redis PING without the fallback masking applied to its other methods. health.ts now reports this as a new `sharedStore` check.
|
@Princessdada is attempting to deploy a commit to the Khubair Nasir's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthrough
ChangesShared store ping contract
Sequence DiagramsequenceDiagram
participant Client
participant HealthRoute
participant SharedStore
Client->>HealthRoute: GET /health
HealthRoute->>SharedStore: ping()
alt ping succeeds
SharedStore-->>HealthRoute: true
else ping throws or fails
SharedStore-->>HealthRoute: false
end
HealthRoute-->>Client: status with checks.sharedStore
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Bug
UpstashStoreis designed to fall back to an in-memory store on any Redis error, which is the right call-site behavior (a Redis outage shouldn't take the API down). But every fallback decision today is only visible via a scatteredlogger.warn()inside whichever method happened to fail. There's no operator-facing signal that the multi-replica abuse-control guarantee (rate limits, WS connection caps, auth bans — all documented at the top ofshared-store.ts) has silently degraded to per-replica enforcement across the whole deployment./healthhas no idea this subsystem exists.Fix
Add
ping(): Promise<boolean>to theSharedStoreinterface:InMemoryStore.ping()is trivially alwaystrue— it's the deliberately chosen single-replica backend, not a degraded state.UpstashStore.ping()issues a real RedisPINGand returnsfalseon any failure — deliberately not routed through the fallback-to-memory path the other methods use, since the whole point here is to report the real backend's reachability rather than mask it.health.tsnow callsgetSharedStore().ping()and reports it as a newchecks.sharedStorefield, following the same pattern as the existingdb/rpc/wschecks.Test plan
ping() liveness probe (BUG-111)block totests/middleware/shared-store.test.ts:InMemoryStorealways true;UpstashStoretrue onPONG, false on network failure, false on a non-PONG response.shared store health check (BUG-111)block totests/routes/health.test.ts:checks.sharedStoreflips false whenping()resolves false or throws, true when it resolves true; updated the existing "all checks fail" test to also mockping()failing so it still exercises the true all-down case.src/middleware/shared-store.ts+src/routes/health.tsviagit stash, confirmed all 8 new/updated tests fail against the unfixed code (missingpingon the interface/check), restored the fix.adl.test.ts).tsc --noEmitclean.Summary by CodeRabbit
New Features
Bug Fixes
Tests