fix(web): filter browser extension probe errors from window.onerror handler #SUPERLOG - #451
Open
superlog-app[bot] wants to merge 1 commit into
Open
fix(web): filter browser extension probe errors from window.onerror handler #SUPERLOG#451superlog-app[bot] wants to merge 1 commit into
superlog-app[bot] wants to merge 1 commit into
Conversation
…andler #SUPERLOG Delivery-Id: f9a7e142a6be3081816cea06c8eb3f45c0d36771531d8ac0ba744c09a59044c6 Delivery-Base: main
| // Browser extensions and browser-native bridges (e.g. Firefox reader mode, | ||
| // MetaMask) inject short probe scripts that execute as "global code" at | ||
| // line 1 of the page URL — not inside any application JS bundle. When those | ||
| // probes throw, window.onerror fires with filename === the page href and |
Contributor
Author
There was a problem hiding this comment.
metrics · warning — Count filtered browser-extension probe errors
Increment a counter (e.g. browser_extension_probe_errors_filtered_total) at the filter return so operators can detect if the heuristic is over-broad or if legitimate errors are being silently dropped. Without it, a regression where real errors match lineno === 1 && filename === window.location.href would be invisible.
Suggested change
| // probes throw, window.onerror fires with filename === the page href and | |
| if (event.lineno === 1 && event.filename === window.location.href) { | |
| filteredProbeErrorsCounter.add(1, { "filter.reason": "extension_probe" }); | |
| return; | |
| } |
Useful? React with 👍 / 👎.
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.
Summary
The
@superlog/webproduction app is capturing browser extension and browser-native script errors as real application exceptions, creating noisy incidents for errors likeReferenceError: Can't find variable: __firefox__andTypeError: undefined is not an object (evaluating 'window.ethereum.selectedAddress = undefined').Root Cause
Browser extensions (MetaMask, crypto wallets) and Firefox iOS's internal bridge inject short probe scripts that run as
global codeat line 1 of the page URL (https://superlog.sh/). When these probes throw — becausewindow.__firefox__orwindow.ethereumdon't exist on the page —window.onerrorfires. Thewindow.addEventListener("error", ...)handler ininstrumentation.tshad no guard to distinguish these external probes (filename = page href, lineno = 1) from real application JS errors (filename =/assets/index-*.js, specific lineno). All three grouped issues showcode.file: "https://superlog.sh/"andcode.line.number: 1with column numbers ≤ 19 — unmistakably inline/injected scripts, not application bundle code.Remediation
Added a one-line guard in the
window.errorlistener to skip events whereevent.lineno === 1 && event.filename === window.location.href. This is the canonical signature of browser-injected/extension script errors. Application bundle errors always reference a path under/assets/, so they are unaffected.Related incident: d0faa423-c322-4197-90e2-4531c243501f
Was this PR helpful? Leave feedback — goes straight to the Superlog team.
Summary by cubic
In
@superlog/web, ignore browser extension and browser-native probe errors so they don’t create noisy incidents. Adds a guard inwindow.onerrorto skip events that come from line 1 of the page URL (injected probes), not app code.window.onerrorevents whereevent.lineno === 1andevent.filename === window.location.href./assets/are unaffected.Written for commit e100202. Summary will update on new commits.