Repository navigation
Description
Summary
Close two runtime failure classes observed around the v0.12.70 stable release:
- The Rust desktop backend caches a Redis multiplexed connection and does not invalidate/reconnect it after transport failures. Once stale, TTS and other metered paths can fail repeatedly with
broken pipe. - Gemini proxy requests repeatedly time out at the infrastructure boundary. These inherited provider failures must have explicit timeout/fallback ownership and must not be conflated with desktop-release regressions.
This issue is independently deployable from the release-platform work. It should land before the next stable desktop release so candidate probes can enforce the corrected behavior.
Evidence: stale Redis connection
Before the .70 backend cutover, revision desktop-backend-00883-tcp produced at least 74 POST /v1/tts/synthesize 503 responses from 00:41:53Z to 01:08:30Z. Each paired with:
tts_synthesize: Redis rate-limit error ... broken pipe
The failures were fast 503s from the fail-closed rate-limit path, not OpenAI TTS latency.
The first known broken pipe on the old revision appeared roughly 31 hours after its deploy. Restarting via the .70 deployment established a fresh connection and immediately restored TTS, but did not prove durable closure.
Code inspection at exact .70 source 2bdd18a7e397b4c7aab8199443def178c0e9b0e0 showed:
- one cached Redis multiplexed connection;
- no invalidation/reconnect path after command transport error;
- TTS rate-limit failure maps to 503 to avoid unmetered server-key use.
The exact ten-minute post-cutover soak on desktop-backend-00884-wvg processed 1,477 requests. TTS was 342/342×200 with zero broken-pipe/TTS-error logs. Later monitoring produced another 353×200 and one expected rate-limit 429 with zero broken pipes. This proves immediate recovery after restart, not long-lived resilience.
Evidence: Gemini timeout class
During the same ten-minute new-revision window:
- 11 requests returned 504;
- all were POST Gemini 2.5 Flash
generateContent; - each failed at approximately the 90-second upstream timeout;
- the same class existed on
.0before cutover.
These timeouts were unrelated to release identity, update feeds, Redis or TTS. They need separate ownership so release dashboards do not report one undifferentiated 5xx signal.
Required Redis changes
- Wrap connection acquisition behind a recoverable owner rather than exposing one permanently cached connection.
- Classify Redis command errors into:
- retryable transport/connection errors;
- non-retryable command/data errors;
- capacity/auth/configuration errors.
- On retryable transport error:
- invalidate the cached connection generation;
- reconnect with bounded jitter;
- retry only operations that are safe/idempotent;
- allow one caller to reconnect while others wait or fail boundedly.
- Do not fail open for metering/rate limiting.
- Prevent retry amplification during Redis outage.
- Expose bounded telemetry:
- operation;
- failure class;
- reconnect attempted/succeeded/exhausted;
- outcome recovered/degraded/exhausted;
- connection generation/age bucket, not credentials or user data.
- Apply the common recovery path to TTS, chat/Gemini metering and every Rust desktop Redis consumer.
- Add readiness/dependency state that distinguishes service process health from Redis operational readiness.
Required Gemini changes
- Define an intentional client timeout below the infrastructure hard ceiling.
- Propagate cancellation when callers disconnect.
- Bound retries to safe request types and total deadline.
- Use shared fallback telemetry when provider/mode changes; do not invent an unbounded metric.
- Decide the user-visible outcome for:
- provider timeout;
- caller cancellation;
- rate limit;
- upstream 5xx;
- exhausted fallback.
- Separate provider timeout SLO/alerts from release health.
- Preserve request correlation without logging prompts or response bodies.
Fault-injection tests
Redis tests must cover:
- server closes an established connection;
- broken pipe on the first command;
- concurrent callers during reconnect;
- reconnect succeeds and the original safe operation recovers once;
- reconnect exhausts and TTS remains fail closed;
- non-idempotent operations are not duplicated;
- auth/configuration error is not retried as transport;
- repeated stale cycles do not leak tasks/connections;
- process restart is not required for recovery.
Gemini tests must cover:
- upstream hangs past client deadline;
- caller disconnect cancels upstream;
- retry/fallback stays inside total budget;
- timeout telemetry is attributed to provider/model/route with bounded labels;
- release-health aggregation excludes known provider timeouts while still reporting them.
Production verification
- Deploy as a named candidate/zero-traffic revision when the promotion engine supports it; until then use a controlled backend rollout with exact rollback revision.
- Force a Redis connection close in a safe test seam and prove reconnect without process restart.
- Exercise authenticated TTS through the real rate-limit path.
- Observe representative natural traffic for longer than the prior short soak; record connection age.
- Verify Gemini timeout rate and latency distribution separately.
- Roll back on retry amplification, duplicate metering, unmetered fail-open, or a new TTS failure cluster.
Acceptance criteria
- Forced stale Redis connection recovers without process restart.
- TTS never bypasses metering.
- Safe operations retry at most once per bounded policy.
- Non-idempotent operations are not duplicated.
- Reconnect concurrency is bounded.
- All Redis consumers use the shared recovery owner.
- TTS/Redis metrics have honest denominators.
- Gemini timeout policy is explicit and tested.
- Provider timeouts and release regressions are separately visible.
- Production evidence includes exact revision, fault injection and natural-traffic window.
Related issue pack
- Desktop Release V2: build once and promote one immutable app/backend release unit #9526 — immutable app/backend release unit and compatibility contract (foundation)
- Desktop Release V2: safe resumable beta/stable promotion engine with candidate-first rollback #9525 — resumable candidate-first promotion and rollback engine
- Desktop Release V2: generated evidence, release doctor, and enforceable beta-to-stable drift gates #9523 — generated evidence, release doctor, and beta-to-stable drift gates
- Desktop backend: recover stale Redis connections and isolate Gemini timeout failures from release health #9524 — Redis recovery and Gemini timeout isolation for desktop-backend health
Dependency graph
#9526 ──> #9525 ──> blocking phase-aware gates in #9523
└────────────────> canonical identity checks in #9523
#9524 ── independent implementation lane
├────────────────> semantic runtime probes consumed by #9525
└────────────────> bounded runtime telemetry consumed by #9523
Dependencies and rollout ordering
- Independent: implementation and production rollout do not depend on Desktop Release V2: build once and promote one immutable app/backend release unit #9526, Desktop Release V2: safe resumable beta/stable promotion engine with candidate-first rollback #9525, or Desktop Release V2: generated evidence, release doctor, and enforceable beta-to-stable drift gates #9523. This should proceed in parallel and preferably land before the next stable desktop-backend promotion.
- Feeds Desktop Release V2: safe resumable beta/stable promotion engine with candidate-first rollback #9525: expose deterministic semantic probes and bounded failure classifications for candidate soak and promotion decisions. The promotion engine itself can be built before this issue lands.
- Feeds Desktop Release V2: generated evidence, release doctor, and enforceable beta-to-stable drift gates #9523: provide denominator-backed metrics and explicit Redis-vs-provider timeout ownership for generated evidence and alerts.
- Must not be coupled to app release identity: this is runtime resilience. It should remain deployable and reversible independently of a macOS app release.
- Recommended landing order: fault-injection tests; reconnect/retry implementation with bounded attempts; deploy to beta; verify recovery and metric cardinality; deploy to stable; establish baselines; only then enable dependent hard gates in Desktop Release V2: safe resumable beta/stable promotion engine with candidate-first rollback #9525/Desktop Release V2: generated evidence, release doctor, and enforceable beta-to-stable drift gates #9523.
Activity
Recover stale Redis connections and isolate Gemini timeouts (#9533)
Git-on-my-level commentedon Jul 13, 2026
Implementation packet — live rollout state and fresh bounded telemetry (2026-07-13)
Code versus deployment status
main.desktop-backendis serving 100% from revisiondesktop-backend-00507-sjh; its deployed commit contains the Recover stale Redis connections and isolate Gemini timeouts #9533 merge.desktop-backendis serving 100% fromdesktop-backend-00884-wvgat commitf755063f11ea; that commit does not contain Recover stale Redis connections and isolate Gemini timeouts #9533.Therefore, this is no longer an open-ended implementation-discovery task. The code path is available in dev; the remaining work is behavioral qualification and a separately approved production rollout.
Fresh six-hour error snapshot
504s, 2 Gemini502s, plus 4 screen-activity sync503s504s, 33 TTS synthesize503s, and smaller residual bucketsThe dev sample is below the query cap; production counts are lower bounds. The merged change must therefore be evaluated by bounded reconnect/fallback behavior and user-visible outcome, not by expecting upstream Gemini
504s to disappear.Implementation/qualification direction
No additional cloud discovery is required for an implementer to understand the remaining work. A production traffic change remains an approval-gated operation.
Git-on-my-level commentedon Jul 13, 2026
Root cause confirmed — current dev 504s are a self-imposed 70-second cutoff
Fresh dev evidence establishes a concrete regression:
desktop-backendallowstimeoutSeconds: 300.desktop-backend-00507-sjhand runs the current proxy contract withGEMINI_ATTEMPT_TIMEOUT = 70sand outerGEMINI_TOTAL_TIMEOUT = 75s.generateContent504s. Their request latencies cluster at approximately70.0s, and matching application logs stategemini_proxy: upstream request timed out: error sending request: operation timed out.This is not a Cloud Run deadline and should not be treated as generic provider instability. The proxy is cutting off work that the infrastructure and client are prepared to wait for.
Existing precedent and repair shape
Closed #9135 previously fixed this exact class by deriving the proxy deadline from Cloud Run's 300-second contract, reserving 60 seconds of response headroom (about 240 seconds usable), with evidence that valid long-context Gemini calls complete beyond 90 seconds. That timeout contract is no longer present in the current proxy implementation after later parallel proxy changes.
Repair by restoring the platform-derived deadline contract on top of the current telemetry/metering/error-classification code; do not revert the newer proxy work wholesale.
Required dev-first tests/qualification:
fix(desktop): restore Gemini platform deadline (BasedHardware#9644)