Repository navigation
fix: respect context cancellation in gateway rate limiter - #6751
Merged
atzoum merged 5 commits intoMar 11, 2026
Merged
Conversation
…miter and downstream components respect request cancellations.
… avoid stat increments on dropped connections and add tests.
🔒 Scanned for secrets using gitleaks 8.30.0
…ests.Prevents panic on duplicate Subscribe calls in nested Ginkgo contexts.
1 task done
atzoum
approved these changes
Mar 11, 2026
mihir20
approved these changes
Mar 11, 2026
This was referenced Mar 16, 2026
Merged
itsmihir
pushed a commit
that referenced
this pull request
Mar 16, 2026
🤖 I have created a release *beep* *boop* --- ## [1.70.0-rc.1](v1.69.0...v1.70.0-rc.1) (2026-03-16) ### Features * add a scheduled release cut workflow to cut release branches ([#6739](#6739)) ([ab887ac](ab887ac)) * infer OAuth type from account definition when destination supports accounts ([#6718](#6718)) ([00d1755](00d1755)) ### Bug Fixes * false sanity check failure due to empty response ([#6762](#6762)) ([0384603](0384603)) * gateway request blocked in store jobs blocking all other requests ([#6760](#6760)) ([ca4d514](ca4d514)) * respect context cancellation in gateway rate limiter ([#6751](#6751)) ([589251a](589251a)) * update prerelease branch versioning format in scheduled release workflow ([#6745](#6745)) ([fede9e4](fede9e4)) ### Miscellaneous * add check for pseudo-version dependencies in rudderlabs modules ([#6737](#6737)) ([55ecd10](55ecd10)) * bump rudder-go-kit to 0.73.0 ([#6753](#6753)) ([1743f6b](1743f6b)) * remove gunicorn and add darwin compatibility ([#6742](#6742)) ([392d1f4](392d1f4)) * use latest retryablehttp client ([#6754](#6754)) ([629f036](629f036)) * user rudo docker image for partition migration integration tests ([#6757](#6757)) ([5022fbd](5022fbd)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
itsmihir
pushed a commit
that referenced
this pull request
Mar 17, 2026
🤖 I have created a release *beep* *boop* --- ## [1.70.0](v1.69.0...v1.70.0) (2026-03-16) ### Features * add a scheduled release cut workflow to cut release branches ([#6739](#6739)) ([ab887ac](ab887ac)) * infer OAuth type from account definition when destination supports accounts ([#6718](#6718)) ([00d1755](00d1755)) ### Bug Fixes * false sanity check failure due to empty response ([#6762](#6762)) ([0384603](0384603)) * gateway request blocked in store jobs blocking all other requests ([#6760](#6760)) ([ca4d514](ca4d514)) * respect context cancellation in gateway rate limiter ([#6751](#6751)) ([589251a](589251a)) * update prerelease branch versioning format in scheduled release workflow ([#6745](#6745)) ([fede9e4](fede9e4)) ### Miscellaneous * add check for pseudo-version dependencies in rudderlabs modules ([#6737](#6737)) ([55ecd10](55ecd10)) * bump rudder-go-kit to 0.73.0 ([#6753](#6753)) ([1743f6b](1743f6b)) * remove gunicorn and add darwin compatibility ([#6742](#6742)) ([392d1f4](392d1f4)) * use latest retryablehttp client ([#6754](#6754)) ([629f036](629f036)) * user rudo docker image for partition migration integration tests ([#6757](#6757)) ([5022fbd](5022fbd)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
This was referenced Mar 22, 2026
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.
Description
Hi @atzoum @mihir20 ,
Continuation of #6694
This PR updates the gateway rate limiter in handle.go to propagate the request context (req.ctx) instead of context.TODO(), ensuring rate limit checks respect client disconnections. It also guards error logging and metric increments behind a req.ctx.Err() == nil check so that context cancellation errors are not mistakenly counted as rate limiter failures.
Changes
1.) gateway/handle.go : Pass req.ctx to CheckLimitReached. Only log rate_limiter_error and increment stats when the context is still active. Return req.ctx.Err() early if the context was cancelled.
2.) gateway/types.go : Add ctx context.Context field to webRequestT, populated from req.Context() in addToWebRequestQ.
3.) gateway/gateway_test.go: Add .AnyTimes() to the Subscribe mock to support nested Ginkgo contexts. Add AfterEach for gateway cleanup. Add 3 tests covering:
After this changes, my 3 test cases, which are failing is now running by using these commands :
1.) cd rudder-server/gateway
2.) go test -v -run='^TestGateway$' -ginkgo.focus='rate limit'
Please review the changes and let me know is there any changes for the enhancement.
Thank you