Skip to content

RateLimitingMiddleware implements IDisposable to avoid leaking timers - #66435

Open
kvantetore wants to merge 3 commits into
dotnet:mainfrom
kvantetore:fix/disposable-ratelimitingmiddleware
Open

kvantetore wants to merge 3 commits into
dotnet:mainfrom
kvantetore:fix/disposable-ratelimitingmiddleware

Conversation

@kvantetore

@kvantetore kvantetore commented Apr 23, 2026 •

Copy link
Copy Markdown

RateLimitingMiddleware implements IDisposable to avoid leaking timers

Change RateLimitingMiddleware from convention-based to DI activated and implement IDisposable in order to not leak memory

Description

Most of the implementation is pretty straight forward. The only thing that feels a bit off is the handling of options passed to UseRateLimiter(..., RateLimiterOptions options) (as opposed to the more idiomatic version passing options during DI registration). I moved some of the initialization code to an internal Initialize(...) and call the initialize method both from the constructor and from UseRateLimiter(..., RateLimiterOptions options)

Fixes #66434

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.

@dotnet-policy-service dotnet-policy-service Bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Sep 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares community-contribution Indicates that the PR has been added by a community member pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RateLimitingMiddleware never disposes PartitionedRateLimiter causing memory leak

1 participant