Skip to content

0.327.0

Choose a tag to compare

@botberry botberry released this 31 Aug 22:28
· 6 commits to main since this release
4837f62

This release fixes a potential unbounded memory growth in the ParserCache and
ValidationCache extensions.

Both extensions previously defaulted to maxsize=None, which creates an
unbounded functools.lru_cache. On a network-exposed endpoint with one of these
extensions enabled, a client sending many distinct query texts could grow the
server's memory without limit.

The default is now a bounded LRU cache of 128 entries, matching the
functools.lru_cache default. Existing behavior can be restored by explicitly
opting in to an unbounded cache:

import strawberry
from strawberry.extensions import ParserCache, ValidationCache

schema = strawberry.Schema(
    Query,
    extensions=[
        ParserCache(maxsize=None),  # explicitly unbounded
        ValidationCache(maxsize=100),
    ],
)

Only use maxsize=None when the set of distinct query texts reaching the server
is trusted and bounded.

This release was contributed by @patrick91 in #4606