Repository navigation
fix(relay): never cache a region hint from a one-region catalog - #19349
Conversation
The director lists only regions with a serving cell, so a roll wave shortens the catalog to one entry. The resolver required only every *listed* region to be measured, so that lone region won against nothing and was cached for 24 h: a US desktop refreshing while US cells rolled published asia-east2 for a day, the incident #19233 was written to end. Now fewer listed regions than the fleet serves withholds the hint (1 h no-hint TTL), the same outcome as an unmeasurable peer.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughRelay region selection now withholds a hint when the director catalog lists fewer regions than the known relay regions. It writes a one-hour no-hint cache entry in this case. Tests now use two-region catalogs for fallback, corrupt-cache recovery, and cache-expiry scenarios. A new test verifies the incomplete-catalog behavior and its cache contents. Merge Risk: ⚪ Minimal · up to Incomplete relay catalogs now produce a short-lived no-hint result instead of pinning users to the lone reported region. The intended cache behavior is covered, with no remaining concrete merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description clearly explains the bug, the fix, the scope, and verification results. However, it omits most required template sections, including ELI5, What Changed, an explicit Linked Issue entry, Visual Proof or N/A, Testing checkboxes, Review, Agent skill upstream boundary, Notes, and the Checklist. Resolution Complete the repository template. Add the missing required sections and provide an explicit issue reference such as
✨ Finishing Touches📝 Generate docstrings
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 |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
One added condition in RelayRegionPreferenceResolver.refresh() plus matching test updates, so a region hint is only produced when the director's catalog lists every region in the fleet.
relay-region-preference.ts—refresh()appendsreports.length < RELAY_REGIONS.lengthto the existingmeasurements.length < reports.lengthguard, so a catalog listing fewer regions than the fleet serves (a roll wave) withholds the hint for the 1 h no-hint TTL instead of caching a lone survivor for a day. No new state, cache fields, or log reasons.relay-region-preference.test.ts— two tests that previously asserted a lone-region hint now measure both regions; one new test pins the one-region-catalog case to aregion: null1 h cache and fails without the fix.
The new test genuinely guards the bug: with a healthy one-region catalog, the old code selected and cached that region, so .resolves.toBeUndefined() and region: null both fail pre-fix.
ℹ️ RELAY_REGIONS.length is now a load-bearing "fleet size" proxy
The condition compares the catalog length against the desktop's compile-time RELAY_REGIONS.length, so correctness now assumes the desktop's region list stays in lockstep with the director's actual serving set. Those lists are maintained independently (desktop relay-region-probe.ts vs. the relay's own RELAY_REGIONS), so a version skew where the desktop lists more regions than the fleet currently serves would withhold every hint fleet-wide until the skew resolves. Harmless for the current two-region fleet, but worth remembering if a region is ever added or removed.
Technical details
# Desktop region list vs. director serving set must stay in lockstep
## Affected sites
- src/main/runtime/relay/relay-region-preference.ts:185 — `reports.length < RELAY_REGIONS.length`
## Required outcome
- No change needed for the current fleet. When a region is added, the desktop's `RELAY_REGIONS`
list and the director's serving set must ship so the count matches while that region is rolling out;
otherwise all desktops fall back to `us-central1` for the skew window.
## Open questions for the human (optional)
- Is there an intended future region rollout order that would trigger this skew?DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior review, one follow-up commit tightened a test the fix itself had quietly weakened.
relay-region-preference.test.ts— the "unstable probes" section of'falls back without a hint for corrupt cache, old catalogs, and unstable probes'now measures a two-region catalog (flapping US[15, 10, 20, 400]against stable Asia[300, 200, 205, 210]), so itstoBeUndefined()is attributable to the US path's spread rejection alone, rather than also passing against the new one-region-catalog rule. Before this change the single-region US catalog would have been swallowed byreports.length < RELAY_REGIONS.length, leaving the flap-rejection assertion with no independent teeth.
The change is test-only (3 insertions, 2 deletions); production code is unchanged. pnpm vitest run src/main/runtime/relay/relay-region-preference.test.ts passes 26/26.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Replaces #19322, reduced to the one rule that fixes a reproduced bug. Everything else that PR accumulated over six review rounds (warm-up budgets, incumbent holds, cache markers, self-heal fences, log reason reordering, warning aggregation) is dropped: each of those was a heuristic that invited the next counter-heuristic, and none fixed a reproduced production problem.
Why
The director lists only regions that currently have a serving cell, so a roll wave shortens the catalog to one entry. On main the resolver requires only every listed region to be measured, so that lone region wins against nothing and is cached as a 24 h hint. A US desktop refreshing while US cells roll publishes
asia-east2for a day, which is exactly the incident #19233 ended. Two tests on main pinned this behaviour.What
One condition: fewer listed regions than the fleet serves withholds the hint, the same 1 h no-hint outcome main already uses for an unmeasurable peer. No new state, no new cache fields, no new log reasons. The cost is bounded and known: a desktop that refreshes during the other region's roll wave loses its hint for one hour and lands at the director default, which is
us-central1, the region most desktops want anyway.Diff
relay-region-preference.ts: +3 lines of condition, one comment. The two tests that asserted a lone-region hint now earn it against both regions; their intent (corrupt-cache recovery, expiry bound) is unchanged. One new test: one-region catalog yields no hint with the 1 h TTL, and fails without the fix.Verification
pnpm vitest run src/main/runtime/relay/156/156,pnpm tc:node, oxlint and oxfmt clean.