Description
We have a walk util which we use to walk objects to normalize them.
This is used extensively throughout the SDK, primarily through
sentry-javascript/packages/utils/src/object.ts
Lines 373 to 379 in 0a6e535
@timfish and some others have reported OOM errors on coming from the walk
function - which shows that it is not always super safe to use. We've also seen issues like #4470.
We should try to do a couple things here:
- Profile
normalize
andwalk
, see where the bottlenecks are in various scenarios. It's used in electron and react native also, so it'll be interesting to see the effects on that platform. - Experiment with adding a limit to the number of leaves, not just limiting serialization depth
- Explore going beyond using a
JSON.Stringify
replacer to more a more rigorous object traversal to try to improve efficiency.
We can test potential performance improvements with https://github.com/getsentry/sentry-sdk-benchmark/
In a slightly related note, we also use JSON.stringify
a lot throughout the codebase, and it's not always clear when to use walk
to normalize. We should make the usage consistent, perhaps by extracting into distinct helpers based on the use case. This also means we could have "more expensive" and "less expensive" normalization functions - perhaps that will just alleviate the issue we have here.
Metadata
Metadata
Assignees
Type
Projects
Status
Status