Skip to content

feat(serializer): Add a max_breadth option to limit the items serialized from arrays and objects - #2283

Open
Amoifr wants to merge 1 commit into
getsentry:masterfrom
Amoifr:feat/max-breadth
Open

Amoifr wants to merge 1 commit into
getsentry:masterfrom
Amoifr:feat/max-breadth

Conversation

@Amoifr

@Amoifr Amoifr commented Oct 19, 2026

Copy link
Copy Markdown

Closes #2257

Adds an opt-in max_breadth option (default null, so nothing changes unless it's set). When set, AbstractSerializer stops serializing an array or an object after that many items and adds a {truncated} entry with the number of items left out (e.g. '{truncated}' => '499990 more items'). It applies to both the frame arguments (RepresentationSerializer) and the query bindings (Serializer).

With the reproduction script from the issue: peak memory goes from +241.3 MB to +0.6 MB, and from 613 ms to 2 ms, with max_breadth: 10.

As requested, no _meta is introduced here. Happy to rename the option or change the marker format if you prefer something else!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bound the number of array items serialized in stack frame arguments to limit memory usage on large arrays

1 participant