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
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ describe("filterPosthogBeforeSend", () => {
).toBeNull();
});

it("drops the ResizeObserver loop completed browser warning", () => {
expect(
filterPosthogBeforeSend(
exceptionEvent([
{
type: "Error",
value:
"ResizeObserver loop completed with undelivered notifications.",
},
]),
),
).toBeNull();
});

it("drops the Firefox ResizeObserver loop limit exceeded variant", () => {
expect(
filterPosthogBeforeSend(
exceptionEvent([
{ type: "Error", value: "ResizeObserver loop limit exceeded" },
]),
),
).toBeNull();
});

it("keeps Script error. when stack frames are present", () => {
const event = exceptionEvent([
{
Expand Down
13 changes: 13 additions & 0 deletions packages/web/src/auth/posthog/posthog-exception-filter.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ const CEFSHARP_SCANNER_MESSAGE =
*/
const SCRIPT_ERROR_MESSAGE = "Script error.";

/**
* Benign browser warning fired via `window.onerror` when a ResizeObserver
* callback can't finish notifying within one frame (e.g. it triggers layout
* that would require another cycle). Chrome/Firefox surface it as a script
* error even though nothing threw; it's not actionable on its own.
*/
const RESIZE_OBSERVER_LOOP_MESSAGES = new Set([
"ResizeObserver loop completed with undelivered notifications.",
"ResizeObserver loop limit exceeded",
]);

type ExceptionEntry = {
type?: unknown;
value?: unknown;
Expand Down Expand Up @@ -61,6 +72,8 @@ const isDroppableException = (entry: ExceptionEntry): boolean => {

if (entry.value === CEFSHARP_SCANNER_MESSAGE) return true;

if (RESIZE_OBSERVER_LOOP_MESSAGES.has(entry.value)) return true;

// Opaque cross-origin errors. Keep the rare case where frames somehow
// survived sanitization so a real stack is never discarded.
if (entry.value === SCRIPT_ERROR_MESSAGE && !hasStackFrames(entry)) {
Expand Down