chore: faster sentry + use native polyfills#16025
Merged
Cal-L merged 2 commits intoJul 8, 2025
Merged
Conversation
Contributor
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
d42cd8f to
12ce2f0
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Nodonisko
commented
Jun 3, 2025
Cal-L
reviewed
Jun 3, 2025
Gudahtt
reviewed
Jun 3, 2025
12ce2f0 to
7cdf0c0
Compare
Contributor
Author
|
@Cal-L Here is Sentry issue getsentry/sentry-react-native#4884 |
2ff1155 to
93036e9
Compare
Contributor
Author
|
I removed some polyfills from |
Contributor
There was a problem hiding this comment.
Bug: UTF-8 Encoding Issues in `utf8ToBytes`
The utf8ToBytes function's rewrite introduces three main issues:
- Breaking API Change: The function now returns a
Uint8Arrayinstead of a plain JavaScriptArray, which can break calling code expectingArray.prototypemethods. - UTF-8 Corruption on Truncation: Truncating encoded bytes using
slice(0, units)can split multi-byte UTF-8 characters, leading to invalid sequences. The original implementation carefully avoided this. - Incorrect
unitsParameter Handling: Theunitsparameter's handling for falsy values is inconsistent with the original, causingfalseand empty string ("") to coerce to0instead ofInfinity. Additionally, aunitsvalue of0is still incorrectly treated asInfinityrather than returning an empty result.
patches/@sentry+react-native+6.10.0.patch#L85-L123
metamask-mobile/patches/@sentry+react-native+6.10.0.patch
Lines 85 to 123 in 93036e9
Was this report helpful? Give feedback by reacting with 👍 or 👎
Contributor
|
Merging into feature branch for running tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR could speed up Sentry events processing around up to ~15x. I am not able to consistently reproduce slow Sentry (it depends on how much breadcrumbs and extra data are collected), but performance gain helps even when sending relatively small amounts of extra data. For small event time needed dropped from 100ms to under <10ms. For big events I randomly encountered it dropped from 1s to <100ms.
In future this patch for Sentry might not be necessary, because Sentry team is working on fix in library itself, but it might take some time.
There is also second part of PR modifying
metro.config.jsto use faster native polyfills, this could speed up app in some other places.Related issues
Fixes: #15560
Manual testing steps
I would recommend to run smoke test across whole app because this polyfilled libraries could be used in many places eveywhere in the app.
I would also recommend to verify that events from Sentry are received in Sentry dashboard.
Screenshots/Recordings
Before
Sending big Sentry event before changes on emulator takes around 380ms. For real slow device it's around 800ms.
For small events it's around 100ms on real device.
After
After changes it takes around 40ms to send big event and around 80ms on real device.
For small events on real device it's around 10ms.
Pre-merge author checklist
Pre-merge reviewer checklist