fix(runner): retain the active rate limiter pointer - #2654
root-Manas wants to merge 1 commit into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. Walkthrough
ChangesRunner rate limiter
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable merge-blocking issue is identified; the change is ready for normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The runner now uses the same limiter instance for request pacing and shutdown. The change does not expose a new entrypoint or change rate-limit options. A construction-failure cleanup gap remains, but the evidence does not show that this change introduced or worsened it. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
A rabbit checks the tokens bright Comment |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The regression test does not deterministically prove the worker and runner share the same limiter instance.
Review effort: Lite
Findings: None
What changed in this PR
This PR fixes runner rate-limiter initialization by retaining the live limiter pointer instead of copying its state.
Changes:
- Stores
*ratelimit.LimiterinRunner. - Adds regression coverage for finite and unlimited rate-limiting modes.
| File | Summary |
|---|---|
runner/runner.go |
Retains constructor-returned limiter pointers. |
runner/ratelimit_test.go |
Adds rate-limiter state and cleanup tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
On the regression-test concern: the finite-mode tests check the counter after The fixed tests passed ten repeated runs, including the earlier Linux race run. The unlimited-mode test is a race-detector exercise; it doesn't independently prove pointer identity. The 500 ms polling deadline is still sensitive to a heavily stalled test runner. |
Proposed changes
runner.Newcopies a rate limiter after its constructor has started the token worker. The worker can update its atomic count concurrently with that copy, causing race detector failures and leaving the runner's counters disconnected from the worker.Store
*ratelimit.Limiterand retain the constructor result for unlimited, per-second, and per-minute modes. ExistingTakeandStopcalls use the same live instance. CLI rate-limit behavior is unchanged.Fixes #2653.
Proof
devreproduced the initialization race withGOMAXPROCS=2 go test -p 2 -race ./runner -run TestRunner_duplicate -count=10.GOMAXPROCS=2 go test -p 2 -race ./runner -run 'TestRunner.*RateLimiter|TestRunner_duplicate' -count=10(128.307 seconds).go test -p 2 ./....go vet -p 2 ./...andgo build -p 2 ./cmd/httpx.git diff --checkpassed. The repository's separate integration harness and hosted CI have not been run locally.Checklist
devbranchSummary by CodeRabbit