Skip to content
Merged
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
7 changes: 7 additions & 0 deletions apps/docs/lib/sentry-filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ const ignoreErrors: RegExp[] = [
// Chromium's LevelDB storage (used by extensions and embedding browsers) failing to create a
// file on a full disk or a locked profile. This build doesn't use IndexedDB.
/^Non-Error promise rejection captured with value: IO error: .*\.ldb: Unable to create writable file\b/,
// A host app or browser evaluating its own snippet; the only frame is <anonymous>:1:1.
/^ReferenceError: LIDNotifyId is not defined$/,
// Browser features or extensions requesting Picture-in-Picture without a user gesture.
/^NotAllowedError: The request is not triggered by a user activation\.$/,
// Android in-app browsers (XBrowser family) injecting autofill/CSS scripts that call their own
// missing bridge globals.
/^ReferenceError: (?:sw|x)browser is not defined$/,
];

export const sentryEventFilters = { allowUrls, ignoreErrors };
67 changes: 67 additions & 0 deletions apps/docs/scripts/sentry-filters.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,73 @@ test("keeps other IO error rejections", () => {
assert.equal(kept(exception("UnhandledRejection", message)), true);
});

test("drops a host script's undefined LIDNotifyId global", () => {
// The host evaluates the snippet, so the only frame is <anonymous> and allowUrls passes.
const evaluated = { filename: "<anonymous>", lineno: 1, colno: 1, in_app: true };
assert.equal(kept(exception("ReferenceError", "LIDNotifyId is not defined", [evaluated])), false);
});

test("keeps other undefined globals from an evaluated script", () => {
const evaluated = { filename: "<anonymous>", lineno: 1, colno: 1, in_app: true };
for (const value of ["LIDNotifyIdx is not defined", "docsSearch is not defined"]) {
assert.equal(kept(exception("ReferenceError", value, [evaluated])), true, value);
}
});

test("drops a Picture-in-Picture request made without a user gesture", () => {
// Browser features or extensions call it on the page's video; the only frame is native.
const native = { filename: "[native code]", function: "requestPictureInPicture", in_app: true };
const value = "The request is not triggered by a user activation.";
assert.equal(kept(exception("NotAllowedError", value, [native])), false);
});

test("keeps other NotAllowedError rejections", () => {
const native = { filename: "[native code]", function: "requestFullscreen", in_app: true };
const value = "Permission denied by the user.";
assert.equal(kept(exception("NotAllowedError", value, [native])), true);
});

test("drops XBrowser's injected autofill script calling its missing bridge global", () => {
// XBrowser-family browsers inject via evaluateJavascript; the throw site is <anonymous>, so
// allowUrls sees only Sentry's setTimeout wrapper in our chunk (DOCS-ENGINE-16).
const timerWrapper = {
filename: "app:///_next/static/chunks/3u-vo9sql_7c2.js",
function: "n",
lineno: 5,
colno: 14159,
in_app: true,
};
const autofill = {
filename: "<anonymous>",
function: "execute_auto_fill",
lineno: 1,
colno: 226,
in_app: true,
};
const event = exception("ReferenceError", "xbrowser is not defined", [timerWrapper, autofill]);
assert.equal(kept(event), false);
});

test("drops XBrowser's injected CSS script calling its missing bridge global", () => {
// Reaches global_handlers.onerror with only <anonymous> frames, so allowUrls passes
// (DOCS-ENGINE-17).
const frames = [
{ filename: "<anonymous>", lineno: 1, colno: 1669, in_app: true },
{ filename: "<anonymous>", function: "needInjectCss", lineno: 1, colno: 1410, in_app: true },
];
assert.equal(kept(exception("ReferenceError", "swbrowser is not defined", frames)), false);
});

test("keeps other undefined *browser globals from an injected script", () => {
const frames = [
{ filename: "<anonymous>", lineno: 1, colno: 1669, in_app: true },
{ filename: "<anonymous>", function: "needInjectCss", lineno: 1, colno: 1410, in_app: true },
];
for (const value of ["zzbrowser is not defined", "browser is not defined"]) {
assert.equal(kept(exception("ReferenceError", value, frames)), true, value);
}
});

test("keeps errors thrown by this build's code", () => {
const frames = [ourFrame];
assert.equal(
Expand Down
Loading