fix: Handle missing GitHub raw button gracefully - #162
Open
sentry[bot] wants to merge 1 commit into
Open
Conversation
Bundle ReportChanges will increase total bundle size by 774 bytes (0.12%) ⬆️. 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 found" issue (BROWSER-EXTENSION-SA) which occurred when the extension attempted to locate GitHub's
[data-testid="raw-button"]element.Root Cause:
The error stemmed from the extension querying for the 'Raw' button immediately upon page load or
soft-nav:endevents. This often happened before GitHub's DOM was fully rendered, or in cases where the button might legitimately be absent (e.g., for certain file types or GitHub UI variations). The previous implementation would throw an error if the element was not found instantly.Solution:
waitForElementUtility: Introduced a new asynchronous utility functionwaitForElementinsrc/content/github/file/utils/waitForElement.ts. This utility uses aMutationObserverto efficiently wait for a specified DOM element to appear within a given timeout, resolving with the element or rejecting with a customElementNotFoundError.document.querySelectorcalls withawait waitForElementincreateCoverageButton()(main.tsx) andcreateDropdown()(dropdown.tsx).ElementNotFoundErrorclass to provide specific error identification.try/catchblock inmain.tsxand added.catch()handlers to thecreateDropdowncalls. These now specifically check forElementNotFoundErrorand, if caught, log a message to the console and return early without reporting to Sentry. This prevents unnecessary error reports for expected scenarios where the 'Raw' button might not be present or takes longer to render.Fixes BROWSER-EXTENSION-SA
This PR was automatically generated by Sentry. You can adjust this setting at any time.