What happened?
When installed, ErrorHandlingMiddleware records failures under keys that include the JSON-RPC method name and keeps those counters in an in-memory dictionary for the middleware's lifetime. Unsupported methods reach the error handler, so requests with distinct method names create distinct retained keys.
In a local in-process reproduction, 500 requests with different unsupported method names each returned the expected method-not-found error, while get_error_stats() retained 500 separate keys. The retained state therefore grows with the number of distinct failing method strings. This applies only when ErrorHandlingMiddleware is installed; the default configuration is unaffected.
Could unknown method names be aggregated or the statistics map be bounded?
Example Code
Version Information
- FastMCP main: `5baeacfe20eca735cb949564b4915f93a622b916`
- Python: 3.12.15
- OS: macOS 15.0.1 arm64
What happened?
When installed,
ErrorHandlingMiddlewarerecords failures under keys that include the JSON-RPC method name and keeps those counters in an in-memory dictionary for the middleware's lifetime. Unsupported methods reach the error handler, so requests with distinct method names create distinct retained keys.In a local in-process reproduction, 500 requests with different unsupported method names each returned the expected method-not-found error, while
get_error_stats()retained 500 separate keys. The retained state therefore grows with the number of distinct failing method strings. This applies only whenErrorHandlingMiddlewareis installed; the default configuration is unaffected.Could unknown method names be aggregated or the statistics map be bounded?
Example Code
Version Information