Skip to content

[NoQA] Drop Google Translate stack-overflow noise from Sentry - #103459

Merged
mountiny merged 7 commits into
Expensify:mainfrom
software-mansion-labs:google-translate-sentry-filter
Oct 12, 2026
Merged

mountiny merged 7 commits into
Expensify:mainfrom
software-mansion-labs:google-translate-sentry-filter

Conversation

@WojtekBoman

@WojtekBoman WojtekBoman commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Adds googleTranslateRecursionNoiseFilterIntegration, a web-only Sentry event processor that drops the RangeError: Maximum call stack size exceeded raised when Chrome (iOS and desktop) injects Google Translate twice. It drops an event only when it is tagged as third-party, is a single stack-overflow RangeError, and every frame carries a line number and comes from a dot-less URL: the page URL or Translate's own m=el_main script. Our bundle chunks all have a dot, so App errors never match, and a wasm frame compiled without a URL has no line number, so a stack overflow in our own wasm code is kept.

The filter is intentionally wider than Translate: inline scripts also report under the page URL, so a stack overflow from the Ketch or GTM loaders in web/index.html or a GTM Custom HTML tag is dropped too. None of that is App code, so there is nothing for us to fix there. The loop's line number is not checked, because it moves between Translate builds (226 in APP-M6P, 228 in APP-KFE).

Registered after thirdPartyErrorFilterIntegration in setupSentry, order pinned by a test.

The third_party_code tag both noise filters read now lives in CONST.TELEMETRY.TAGS.THIRD_PARTY_CODE instead of being exported by classCallCheckNoiseFilter, so neither filter depends on the other. The event builder, third-party tags and Sentry client stub the two filter tests shared by copy-paste are moved to tests/utils/SentryEventTestUtils.ts.

Fixed Issues

$ #102044 (comment)
PROPOSAL: #102044 (comment)

Tests

  1. Run npx jest tests/unit/googleTranslateRecursionNoiseFilterTest.ts tests/unit/setupSentryIntegrationOrderTest.ts tests/unit/classCallCheckNoiseFilterTest.ts
  2. Verify that all cases pass: the recorded Translate stack overflows (APP-M6P, APP-KQF, APP-M27, APP-MTE, and APP-KFE from an older Translate build with the loop on a different line) are dropped, and untagged events, other error types, chained errors, events with a frame in our chunks, <anonymous> scripts, APP-ZF, APP-2NH, stack overflows with no frames, a RangeError with a different message and a wasm frame with no line number are kept

The third_party_code tag this filter reads is only written in non-dev builds (@sentry/webpack-plugin is skipped for .env and .env.development, so __SENTRY_APPLICATION_KEY_STAMPED__ is false and thirdPartyErrorFilterIntegration is not installed), while the Sentry debug toggle and the [SENTRY] console logs only exist in dev. To exercise the filter locally, turn tagging on in dev with this temporary change:

  1. In config/rsbuild/rsbuild.common.ts, change the __SENTRY_APPLICATION_KEY_STAMPED__: !!sentryWebpackPlugin define to __SENTRY_APPLICATION_KEY_STAMPED__: true. This installs thirdPartyErrorFilterIntegration. Since no dev chunk is stamped, it tags every event as third-party, which is enough to check that the filter drops the Translate shape and keeps everything else
  2. Run npm run web, open the app in desktop Chrome, sign in, go to Troubleshoot and enable the Sentry debug toggle so events are logged to the console with the [SENTRY] prefix instead of being sent
  3. Reproduce the double injection from the proposal (Chrome iOS cannot be automated, so this does by hand what it does on same-document navigation). In the DevTools console, add the Google Translate element script to the page and translate it to another language. Then add the same script a second time, and type into a text input so there is new text to translate. If the dev Content Security Policy blocks the script, temporarily relax it in web/index.html
  4. Verify that the console shows Uncaught RangeError: Maximum call stack size exceeded with two Translate functions repeating in the stack, and that no [SENTRY] event is logged for it
  5. With the same setup, trigger a regular error from App code (e.g. temporarily throw from a click handler)
  6. Verify that the error is still logged as a [SENTRY] event, so only the Translate stack overflow is filtered
  7. Revert the change from step 1

Post-deploy check: the APP-M6P and APP-KFE event volume in Sentry should drop to zero on the first release that includes this filter.

  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@WojtekBoman WojtekBoman changed the title Drop Google Translate stack-overflow noise from Sentry [NoQA] Drop Google Translate stack-overflow noise from Sentry Oct 8, 2026
@WojtekBoman

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@WojtekBoman

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

Looks good to merge. I found no correctness bugs. The filter fails open: it drops an event only when every condition matches, and App code ships only in dotted chunk files, so it cannot match our own errors. All CI checks pass except Check independent approval.

Optional nits:

  1. Scope is wider than the name. The filter drops any stack overflow whose frames all sit in dot-less URLs. Inline scripts also report under the page URL. That includes the Ketch and GTM loaders in web/index.html:39 and web/index.html:164, plus any GTM Custom HTML tag. Dropping these is safe because none of them is App code. Consider saying so in the JSDoc so nobody assumes the filter is Translate-only.
  2. Comments don't match the fixtures. googleTranslateRecursionNoiseFilter.ts:19 says "Chrome iOS", but APP-MTE is desktop Chrome. Line 8 calls the match "the page URL", but app:///m=el_main is the Translate script's own URL.
  3. Missing Given/When/Then comments. The it.each you changed at setupSentryIntegrationOrderTest.ts:39 has none, and App/CLAUDE.md requires them.
What I checked
  • I traced createReactNativeRewriteFrames. It reduces https://new.expensify.com/home to app:///home, which matches PAGE_URL_FILENAME. App chunks, gtm.js, Ketch boot.js, and the Convert script all keep a dot, so they never match.
  • Known misses: these events are kept, not dropped.
    • A page URL whose last segment has a dot, such as /search?q=a.b.
    • A cycle that includes WebKit [native code] frames.
  • Order: the filter is part of THIRD_PARTY_NOISE_INTEGRATIONS, so it runs after the tagger and after the default rewrite-frames integration. On native, the undefined stub is filtered out in setupSentry.

@dariusz-biela dariusz-biela left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The manual test steps can't be run with a standard build. The third-party tag is only set in non-dev builds, but the Sentry debug toggle and the [SENTRY] logs only exist in dev. So in dev this filter has no tag to read and does nothing. Step 3 also does not say how to make Translate load twice, and the repro in the proposal needed a manual second injection. Please describe that repro with a local change that turns tagging on in dev. Or say that the check is the APP-M6P and APP-KFE event volume after deploy.

@WojtekBoman
WojtekBoman marked this pull request as ready for review October 9, 2026 14:33
@WojtekBoman
WojtekBoman requested review from a team as code owners October 9, 2026 14:33
@melvin-bot
melvin-bot Bot requested review from FitseTLT and flaviadefaria and removed request for a team October 9, 2026 14:33
@melvin-bot

melvin-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown

@FitseTLT Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot removed the request for review from a team October 9, 2026 14:33
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T14:45:46.780134Z d1317ae Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari

@mountiny
mountiny removed the request for review from FitseTLT October 12, 2026 12:29
@mountiny
mountiny merged commit d50bd8d into Expensify:main Oct 12, 2026
39 of 40 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.8-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This PR only adds an internal Sentry filter that drops Google Translate stack-overflow noise from error reports, so nothing users see or do changes.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/cristipaval in version: 9.5.8-5 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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.

5 participants