fix(miner): treat an absent x-ratelimit-remaining header as unknown, not a 0 budget - #9897
Conversation
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-29 19:40:40 UTC
Review summary Nits — 4 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
…not a 0 budget (JSONbored#9678) recordRateLimit did `Number(response.headers.get("x-ratelimit-remaining"))`, but headers.get() returns null for an ABSENT header and Number(null) === 0 (which Number.isFinite accepts). So a forge/reverse-proxy that omits the header made the miner record a remaining budget of 0, and the running Math.min pinned it at 0 for the whole run -- resolveThrottledConcurrency then serialized the entire fan-out to a single in-flight request against a budget that was never reported, defeating the "unknown budget runs at full concurrency" contract discovery-throttle.ts documents. Read the raw header and skip a null or blank/whitespace-only value before converting, matching http-retry.ts's own `remaining != null` guard. A genuinely-present "0" (or any finite number) is still recorded; a present-but-non-numeric value is still skipped by Number.isFinite. The x-ratelimit-reset branch is unchanged. Tests: absent header -> rateLimitRemaining stays null (not 0); a blank header is skipped; a present "0" is still recorded. Closes JSONbored#9678 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9897 +/- ##
===========================================
- Coverage 91.75% 79.37% -12.39%
===========================================
Files 920 282 -638
Lines 113064 58775 -54289
Branches 27214 8680 -18534
===========================================
- Hits 103746 46652 -57094
- Misses 8033 11840 +3807
+ Partials 1285 283 -1002
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Closes #9678
What
recordRateLimitinpackages/loopover-miner/lib/opportunity-fanout.tsdidNumber(response.headers.get("x-ratelimit-remaining")).Headers.get()returnsnullfor an absent header, andNumber(null) === 0— whichNumber.isFiniteaccepts. So a forge or reverse proxy that doesn't emitx-ratelimit-remainingmade the miner record a remaining budget of 0, and the runningMath.minpinned it at0for the rest of the run.resolveThrottledConcurrencythen serialized the entire fan-out to a single in-flight request against a budget that was never reported — defeating the "unknown budget runs at fullbaseConcurrency" contractdiscovery-throttle.tsdocuments. This is reachable in exactly the GitHub-Enterprise/compatible-forge configurationforge-config.tsexists to support.The fix reads the raw header and skips a
nullor blank/whitespace-only value before anyNumber(...)conversion, matching the package's ownhttp-retry.tsremaining != nullguard. A genuinely-present"0"(or any finite number) is still recorded; a present-but-non-numeric value is still skipped byNumber.isFinite. Thex-ratelimit-resetbranch is unchanged.Tests
New cases in
test/unit/miner-opportunity-fanout.test.ts: an absent header leavesrateLimitRemainingnull(not0); a blank/whitespace-only header is skipped; a present"0"is still recorded (real exhaustion isn't lost). Verified: 30/30, non-vacuous (the absent + blank cases fail with the fix reverted),tsc --noEmitclean,git diff --checkclean.