SACGF / SACGF/variantgrid

Rollbar: ignore JS errors thrown by browser extensions

Open Beginner friendly
#1,740 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
30
Forks
3
Avg merge
9h 28m
Merged PRs (30d)
42

Description

🤖 Written by Claude

## Problem

Our Rollbar JS config sets `captureUncaught: true` and `captureUnhandledRejections: true`, which hooks `window.onerror` globally. Browser extensions that inject content scripts into the page share that handler, so **errors thrown entirely inside an extension get reported against whatever VariantGrid page the user had open**.

These are pure noise — there is no VariantGrid frame in the stack, and there is nothing we can do about them server-side. They just make the Rollbar feed harder to read.

Real example seen on a SA Path deployment:

```
[anonymous](chrome-extension://mjkjodlpfcbnmkdgpgcalddmfjfoncap/web_resources/jsAgent/jsAgent.js:12:171828)
- Module load timeout 2400: m_1001
```

`Module load timeout 2400: m_1001` appears nowhere in our codebase — `m_1001` is a bundler module ID from the extension's own build and 2400 is its own load timeout. The single stack frame is the extension's script.

This shows up disproportionately on deployments whose users are on managed SOE machines with a mandated extension installed, but it is not deployment-specific — any user with a noisy extension can generate it.

## Proposed fix

Add `hostBlockList` to `_rollbarConfig`:

```js
hostBlockList: ["^chrome-extension:", "^moz-extension:", "^safari-web-extension:"],
```

`_rollbarConfig` is declared in two places, so both need it:

- `uicore/templates/uicore/page/base.html`
- `uicore/templates/uicore/page/base_external.html`

Filtering on the URL scheme is preferable to `ignoredMessages` with the specific error text — the message string is particular to one extension, whereas the scheme covers the whole class, so we avoid revisiting this every time a new extension turns up.

## How `hostBlockList` behaves

From `matchFrames` in rollbar.js `src/predicates.js`:

- Each list entry is used as a **raw regex** and tested against the full `frame.filename`, scheme included — hence the `^chrome-extension:` style anchors rather than bare hostnames.
- It matches against **every frame** in the trace, not just the top one, returning on first match.
- When there are no frames it returns "not blocked", so cross-origin `Script error.` reports that arrive with no stack still come through. It fails open, which is the direction we want.

### Trade-off worth recording

Because it matches any frame, a genuine VariantGrid error would be suppressed if an extension frame appears mid-stack — e.g. an extension that monkey-patches `addEventListener` and ends up in the trace of a real error. This is expected to be rare, and the suppression is silent.

If that turns out to bite, the more precise alternative is a `checkIgnore(isUncaught, args, payload)` function that only ignores an item when *every* frame is an extension URL. That is more code and would need to live in both templates, so `hostBlockList` seems the right thing to start with.

## Verification

Load a page with a noisy extension enabled and confirm the extension errors stop arriving in Rollbar, while `Test Rollbar JS` on the server status page still reports normally.

Contributor guide

No contributing guide indexed for this repository

Research direction

Inspect the _rollbarConfig declarations in uicore/templates/uicore/page/base.html and uicore/templates/uicore/page/base_external.html, then review the Rollbar hostBlockList behavior described in the issue. Confirm both templates filter browser-extension frames while preserving ordinary errors, and verify with a noisy extension and the server status page’s “Test Rollbar JS” check.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, observability
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
85/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.