fix(sim): keep a region switch routing when its numbers are not numbers - #63
Merged
Conversation
|
@kevin9327 is attempting to deploy a commit to the whoarrryou's projects Team on Vercel. A member of the Team first needs to authorize it. |
Owner
|
LGTM, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two numbers on the region node are read with
Math.floorand then compared, and NaN fails everycomparison, so it survives both readings intact. One of them takes the switch off the air; the other
makes the panel contradict the routing it is derived from.
Measured
One client, one region node, two regions behind it. 200 ticks:
activeRegion: NaNis an outage. NaN is adopted as the live region,state.out[NaN]is nothing,so
regionHealthyis false forever and the switch serves neither region. Every request fails.regions: NaNis quieter and, I think, the more interesting one.regionsTotalreaches the panelas
NaNandregionsHealthyreads 0, because the census is a loop andi < NaNis false on thefirst test. Routing is unaffected — 208 requests are served — so the node reports "0 of NaN regions
healthy" while it is healthily serving one.
decorateStatssays of that census:which is exactly the property NaN removes.
Where it comes from
Not the inspector:
regionsis a number input bounded 1..8 andactiveRegion0..7.isTopologychecks the nine core config numbers —
capacity,serviceMs,serviceCv,queueLimit,hitRate,errorRate,timeoutMs,retries,rps— and neither of these, so a shared link, a.breakscalefile and a restored session carry them through untouched.
Fix
regionCountfalls back to the edge count for anything that is not a finite number, which is thesame thing an absent
regionsalready means.The two places that clamp
activeRegionwere the same four lines written twice; they are now oneconfiguredRegionhelper, which rejects a non-finite value as the first region. Deduplicating themis not incidental — the second copy is in
liveRegionIndex, whose whole job is to answer exactlywhat
pickEdgewould do, so the two must not be able to drift.Tests
src/sim/behaviour-control.region.test.ts, new:activeRegionofNaNstill routes, publishes a real region index and fails nothingregionsofNaNpublishes a real total and counts both regions healthy{ regions: 2, activeRegion: 0 }produce identical completions,which is the check that nothing a reader can build moved
activeRegion: 1still sends everything to the second regionAgainst
main, three of the five fail:How I tested
Windows 11, Bun 1.3.14.
bun run testis 934 passed across 40 files, up from 929 by the five newtests, with nothing else moving.
bun run typecheckandbun run format:checkare clean, andbun run lintreports the same pre-existing warnings inuseVendor.ts,Examples.tsxandTooltip.tsxasmaindoes.Same family as #58, #60, #61 and #62, but this one is not about allocation: the region node's numbers
are small, and what NaN costs here is the routing and the readout rather than the process.