Skip to content

fix(studio): suppress ResizeObserver loop noise from error telemetry#1013

Merged
miguel-heygen merged 1 commit into
mainfrom
feat/studio-suppress-resize-observer
May 21, 2026
Merged

fix(studio): suppress ResizeObserver loop noise from error telemetry#1013
miguel-heygen merged 1 commit into
mainfrom
feat/studio-suppress-resize-observer

Conversation

@miguel-heygen
Copy link
Copy Markdown
Collaborator

Summary

  • Suppress ResizeObserver loop completed with undelivered notifications. errors in the Studio global error handler — this is a benign browser-internal message (not a real bug) that was flooding telemetry with ~18,000 events/month, drowning out actionable errors.
  • The guard checks event.message for "ResizeObserver loop" at the top of the window.addEventListener("error", ...) handler and short-circuits with stopImmediatePropagation() + preventDefault() before reaching trackStudioEvent.

Test plan

  • Open Studio in Chrome/Firefox, resize panels and timeline to trigger ResizeObserver recalculations — verify no unhandled_error telemetry events are emitted for ResizeObserver loop messages.
  • Trigger a real JS error (e.g., via console throw new Error("test")) — verify it still appears in telemetry as unhandled_error.
  • Confirm the browser console no longer shows the ResizeObserver warning (prevented by preventDefault()).

Copy link
Copy Markdown
Collaborator

@jrusso1020 jrusso1020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: COMMENT (would-be APPROVE)

Tiny well-scoped fix using the canonical ResizeObserver loop suppression pattern (event.message.includes(...) + stopImmediatePropagation() + preventDefault() at the top of the global error handler). 6 lines, one file. Holding for James's stamp greenlight.

Sanity checks

  • Scope is correct — studio window only, not preview iframe. The PostHog unhandled_error event originates from packages/studio/src/main.tsx:25 (the studio window's error listener); the preview iframe's errors flow through useConsoleErrorCapture.ts:37-44 into consoleErrors state for the UI's error console, not into telemetry. So suppressing studio-window ResizeObserver noise is sufficient — there's no secondary pipeline still ingesting it.
  • Source of the 18k events/month confirmed plausible. Studio uses ResizeObserver at NLEPreview.tsx:137 (preview stage sizing) and AudioWaveform.tsx:141 (waveform redraw). Both run on user resize / panel adjustment, which fires often.
  • Browser coverage: substring "ResizeObserver loop" matches Chrome's "ResizeObserver loop completed with undelivered notifications." AND Firefox's "ResizeObserver loop limit exceeded". ✓
  • Convention consistency: matches the existing benign-error filter pattern at useConsoleErrorCapture.ts:30 (if (text.includes("favicon")) return;).
  • CI: 23 success / 2 in_progress / 0 failures.

One optional follow-up

The unhandledrejection listener (main.tsx:35) doesn't have a matching guard. In practice, ResizeObserver loop notifications fire as window-error events, not as promise rejections — so this isn't a real source of leakage. But if anyone wraps ResizeObserver in a promise abstraction in the future (or if a library does so under the hood), the noise would resurface there. Optional defense-in-depth: add the same if (...includes("ResizeObserver loop")) return; guard to the rejection listener too. Not blocking; the current fix solves the actual problem.

— Rames Jusso

@miguel-heygen miguel-heygen merged commit 053a47a into main May 21, 2026
35 checks passed
@miguel-heygen miguel-heygen deleted the feat/studio-suppress-resize-observer branch May 21, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants