fix: Gracefully handle missing raw button on GitHub file pages - #163
Open
sentry[bot] wants to merge 1 commit into
Open
fix: Gracefully handle missing raw button on GitHub file pages#163sentry[bot] wants to merge 1 commit into
sentry[bot] wants to merge 1 commit into
Conversation
Bundle ReportChanges will increase total bundle size by 84 bytes (0.01%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: codecov-browser-extension-array-pushAssets Changed:
Files in
|
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR addresses the
Error: Raw button not foundthat occurs when thecreateCoverageButtonfunction insrc/content/github/file/main.tsxcannot find the expected raw button element on a GitHub file page.Previously, if the raw button was not found (e.g., due to GitHub UI variations, timing issues in SPA navigation, or pages where the button is genuinely absent), the function would throw an error. This error, although handled by Sentry, would cause the entire extension processing for that page to crash, leading to a poor user experience and a high volume of Sentry events.
The fix implements the following changes:
createCoverageButtonmodification: The function now returnsundefinedinstead of throwing an error if the[data-testid="raw-button"]element is not found. The function's return type has been updated toHTMLElement | undefined.main()guard clause: A check has been added in themain()function. IfcreateCoverageButton()returnsundefined(meaning the raw button was not found), themain()function will now gracefully exit early, preventing further processing and avoiding any crashes.This change ensures that the extension remains robust and does not crash on pages where the raw button is not present, while still functioning as expected on pages where it is available.
Fixes BROWSER-EXTENSION-1Q
This PR was automatically generated by Sentry. You can adjust this setting at any time.