Repository navigation
fix(ratelimit): keep operator minTime floor when relaxing limiter on headroom (#9763) - #11086
Merged
diegosouzapw merged 1 commit intoAug 23, 2026
Conversation
diegosouzapw
merged commit Aug 23, 2026
376b49d
into
cheaper-inference:release/v3.8.50
9 of 16 checks passed
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…cheaper-inference#9763) (cheaper-inference#11086) Validated on the combined batch board over tip 429b730: static gates clean (changelog, file-size 158 frozen, complexity 2626<=2774, cognitive 1183<=1223, dead-code 409<=416), typecheck:core clean, 70 focused tests green (PR suites 49/49 + auth/combo neighbors 21/21). Operator-configured positive minTime floor now survives the plenty-of-headroom relaxation (resolveMinTime instead of a hard 0). Fixes cheaper-inference#9763. Thank you @pacocartones!
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.
Fixes #9763.
What
updateFromHeadersinopen-sse/services/rateLimitManager.tslearns rate limits from upstreamx-ratelimit-*headers. In the "plenty of headroom" branch (remaining > limit * 0.5) it relaxed the limiter by settingupdates.minTime = 0unconditionally:That
0overwritesresilienceSettings.requestQueue.minTimeBetweenRequestsMs— the minimum gap an operator explicitly configures (for example, to protect a sensitive self-hosted upstream). The override happens silently and persists for the life of the limiter, so a single well-provisioned response effectively disables the operator's throttle until the next restart. That is the behavior reported in #9763.Notably the module already resolves that floor everywhere else through
resolveMinTime(...)—buildLimiterDefaults()usesresolveMinTime(currentRequestQueueSettings.minTimeBetweenRequestsMs), and the RPM-derived assignment a few lines above already clamps withMath.max(0, ...). Only this headroom branch bypassed the floor.Fix
Relax toward the configured floor instead of a hard
0:resolveMinTimereturns0when no floor is configured, so the default (no operator throttle) behavior is unchanged. When a floor is set, headroom still lifts learned throttling down to — but never below — the operator's minimum spacing. Reservoir relaxation is untouched.Test
New
tests/unit/rateLimitManager-mintime-floor-9763.test.tssets an operator floor of 200ms viaapplyRequestQueueSettings, injects a spy limiter through the existing__setLimiterFactoryForTestshook, drives a headroom response (limit=100, remaining=80) throughupdateFromHeaders, and asserts the limiter'sminTimestays at 200. It fails on the current base (observedgot 0) and passes with this change. The three existing tests inrateLimitManager-update-sequencing.test.tsonly exercise the retry-after path, so this branch was previously uncovered.Verified on the
release/v3.8.50base:Changelog
Adds
changelog.d/fixes/9763-ratelimit-mintime-floor.md.