Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions public/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async function handleRequest(event, requestId) {
headers: Object.fromEntries(responseClone.headers.entries()),
},
},
[responseClone.body]
[responseClone.body],
)
})()
}
Expand Down Expand Up @@ -229,7 +229,7 @@ async function getResponse(event, client, requestId) {
keepalive: request.keepalive,
},
},
[requestBuffer]
[requestBuffer],
)

switch (clientMessage.type) {
Expand Down Expand Up @@ -259,7 +259,7 @@ function sendToClient(client, message, transferrables = []) {

client.postMessage(
message,
[channel.port2].concat(transferrables.filter(Boolean))
[channel.port2].concat(transferrables.filter(Boolean)),
)
})
}
Expand Down
51 changes: 51 additions & 0 deletions src/sentry.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import * as Sentry from '@sentry/react'
import { createBrowserHistory } from 'history'

import { setupSentry } from './sentry'

vi.mock('./config', () => ({
default: {
SENTRY_DSN: 'https://examplePublicKey@o0.ingest.sentry.io/0',
SENTRY_ENVIRONMENT: 'test',
API_URL: 'https://api.codecov.io',
NODE_ENV: 'test',
},
}))

vi.mock('@sentry/react', async () => {
const actual =
await vi.importActual<typeof import('@sentry/react')>('@sentry/react')
return { ...actual, init: vi.fn() }
})

const matchesIgnored = (patterns: Array<string | RegExp>, message: string) =>
patterns.some((pattern) =>
typeof pattern === 'string'
? message.includes(pattern)
: pattern.test(message)
)

describe('setupSentry', () => {
it('ignores the adoptedStyleSheets error thrown by browser extensions', () => {
setupSentry({ history: createBrowserHistory() })

const options = vi.mocked(Sentry.init).mock.calls[0]?.[0]
const ignoreErrors = (options?.ignoreErrors ?? []) as Array<string | RegExp>

expect(
matchesIgnored(
ignoreErrors,
`TypeError: can't redefine non-configurable property "adoptedStyleSheets"`
)
).toBe(true)
expect(
matchesIgnored(
ignoreErrors,
'TypeError: Cannot redefine property: adoptedStyleSheets'
)
).toBe(true)
expect(
matchesIgnored(ignoreErrors, 'TypeError: Cannot read properties of null')
).toBe(false)
})
})
9 changes: 8 additions & 1 deletion src/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import { Route } from 'react-router-dom'
import config from './config'

// Custom ignored errors
const customIgnoredErrors: string[] = [
const customIgnoredErrors: Array<string | RegExp> = [
/*
* Browser extensions (e.g. Dark Reader style stylesheet proxies) inject an
* inline script that overrides `document.adoptedStyleSheets`. On Firefox the
* extension's own cleanup fails to redefine the property and throws. Gazebo
* never touches `adoptedStyleSheets`, so this is harmless third-party noise.
*/
/redefine (non-configurable )?property:? "?adoptedStyleSheets/i,
/*
* App throwing an error if it can't find a module. We have resolved this
* with two different methods, we're storing assets from previous builds, as
Expand Down
Loading