fix: handle cross-origin iframe errors during stop handler cleanup#145
Merged
pauldambra merged 3 commits intomainfrom Mar 23, 2026
Merged
fix: handle cross-origin iframe errors during stop handler cleanup#145pauldambra merged 3 commits intomainfrom
pauldambra merged 3 commits intomainfrom
Conversation
When an iframe transitions from same-origin to cross-origin (e.g. via redirect), the browser blocks access to its window properties. This caused stopRecord() to crash when iterating handler cleanup functions, preventing subsequent handlers from running. Wrap each handler call in try-catch, silently ignoring cross-origin frame SecurityErrors while still warning about other unexpected errors. Adopted from upstream rrweb PR #1695 with a more specific error check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00bb6ce0f4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Preserve original error propagation behaviour: only cross-origin iframe SecurityErrors are silently swallowed; all other handler errors are re-thrown so callers can detect genuine cleanup failures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
Author
|
maybe fixes PostHog/posthog-js#2533 |
marandaneto
approved these changes
Mar 23, 2026
Documents why cross-origin iframe errors are expected and safe to ignore during stop handler cleanup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| // or a redirect), executing the handler will throw a | ||
| // "cannot access cross-origin frame" error. | ||
| const msg = String(error); | ||
| const isCrossOriginFrameError = |
There was a problem hiding this comment.
should this also silence for "security policy of the user agent" and "SecurityError"?
or just the type in general
error instanceof DOMException && error.name === 'SecurityError'
1 task
pauldambra
added a commit
that referenced
this pull request
Mar 26, 2026
## Summary - Broadens the error handling in the `record()` stop handler to catch all `SecurityError` variants, not just a specific error message string - Uses `instanceof DOMException && error.name === 'SecurityError'` instead of matching against specific message substrings - Follows up on #145 which was too narrow in its error matching ## Test plan - [x] Existing memory-leaks tests pass (17/17) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
mergify bot
pushed a commit
to doxynix/doxynix
that referenced
this pull request
Mar 26, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [@trpc/client](https://trpc.io) ([source](https://redirect.github.com/trpc/trpc/tree/HEAD/packages/client)) | [`11.15.0` → `11.15.1`](https://renovatebot.com/diffs/npm/@trpc%2fclient/11.15.0/11.15.1) |  |  | | [@trpc/react-query](https://trpc.io) ([source](https://redirect.github.com/trpc/trpc/tree/HEAD/packages/react)) | [`11.15.0` → `11.15.1`](https://renovatebot.com/diffs/npm/@trpc%2freact-query/11.15.0/11.15.1) |  |  | | [@trpc/server](https://trpc.io) ([source](https://redirect.github.com/trpc/trpc/tree/HEAD/packages/server)) | [`11.15.0` → `11.15.1`](https://renovatebot.com/diffs/npm/@trpc%2fserver/11.15.0/11.15.1) |  |  | | [@vitest/coverage-v8](https://vitest.dev/guide/coverage) ([source](https://redirect.github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8)) | [`4.1.1` → `4.1.2`](https://renovatebot.com/diffs/npm/@vitest%2fcoverage-v8/4.1.1/4.1.2) |  |  | | [knip](https://knip.dev) ([source](https://redirect.github.com/webpro-nl/knip/tree/HEAD/packages/knip)) | [`6.0.5` → `6.0.6`](https://renovatebot.com/diffs/npm/knip/6.0.5/6.0.6) |  |  | | [lucide-react](https://lucide.dev) ([source](https://redirect.github.com/lucide-icons/lucide/tree/HEAD/packages/lucide-react)) | [`1.6.0` → `1.7.0`](https://renovatebot.com/diffs/npm/lucide-react/1.6.0/1.7.0) |  |  | | [posthog-js](https://posthog.com/docs/libraries/js) ([source](https://redirect.github.com/PostHog/posthog-js)) | [`1.363.5` → `1.363.6`](https://renovatebot.com/diffs/npm/posthog-js/1.363.5/1.363.6) |  |  | | [posthog-node](https://redirect.github.com/PostHog/posthog-js) ([source](https://redirect.github.com/PostHog/posthog-js/tree/HEAD/packages/node)) | [`5.28.5` → `5.28.6`](https://renovatebot.com/diffs/npm/posthog-node/5.28.5/5.28.6) |  |  | | [vitest](https://vitest.dev) ([source](https://redirect.github.com/vitest-dev/vitest/tree/HEAD/packages/vitest)) | [`4.1.1` → `4.1.2`](https://renovatebot.com/diffs/npm/vitest/4.1.1/4.1.2) |  |  | --- ### Release Notes <details> <summary>trpc/trpc (@​trpc/client)</summary> ### [`v11.15.1`](https://redirect.github.com/trpc/trpc/releases/tag/v11.15.1) [Compare Source](https://redirect.github.com/trpc/trpc/compare/v11.15.0...v11.15.1) ##### What's Changed - fix(www): render sponsor links in static HTML for SEO by [@​shtefcs](https://redirect.github.com/shtefcs) in [#​7285](https://redirect.github.com/trpc/trpc/pull/7285) - fix: error handling with Node VM by [@​znikola](https://redirect.github.com/znikola) in [#​7280](https://redirect.github.com/trpc/trpc/pull/7280) ##### New Contributors - [@​shtefcs](https://redirect.github.com/shtefcs) made their first contribution in [#​7285](https://redirect.github.com/trpc/trpc/pull/7285) - [@​znikola](https://redirect.github.com/znikola) made their first contribution in [#​7280](https://redirect.github.com/trpc/trpc/pull/7280) **Full Changelog**: <trpc/trpc@v11.15.0...v11.15.1> </details> <details> <summary>vitest-dev/vitest (@​vitest/coverage-v8)</summary> ### [`v4.1.2`](https://redirect.github.com/vitest-dev/vitest/releases/tag/v4.1.2) [Compare Source](https://redirect.github.com/vitest-dev/vitest/compare/v4.1.1...v4.1.2) This release bumps Vitest's `flatted` version and removes version pinning to resolve `flatted`'s CVE related issues ([#​9975](https://redirect.github.com/vitest-dev/vitest/issues/9975)). ##### 🐞 Bug Fixes - Don't resolve `setupFiles` from parent directory - by [@​hi-ogawa](https://redirect.github.com/hi-ogawa) in [#​9960](https://redirect.github.com/vitest-dev/vitest/issues/9960) [<samp>(7aa93)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/7aa937776) - Ensure sequential mock/unmock resolution - by [@​hi-ogawa](https://redirect.github.com/hi-ogawa) and **Claude Opus 4.6** in [#​9830](https://redirect.github.com/vitest-dev/vitest/issues/9830) [<samp>(7c065)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/7c06598db) - **browser**: Take failure screenshot if `toMatchScreenshot` can't capture a stable screenshot - by [@​macarie](https://redirect.github.com/macarie) in [#​9847](https://redirect.github.com/vitest-dev/vitest/issues/9847) [<samp>(faace)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/faace1fbe) - **coverage**: Correct `coverageConfigDefaults` values and types - by [@​Arthie](https://redirect.github.com/Arthie) in [#​9940](https://redirect.github.com/vitest-dev/vitest/issues/9940) [<samp>(b3c99)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/b3c992cb2) - **pretty-format**: Fix output limit over counting - by [@​hi-ogawa](https://redirect.github.com/hi-ogawa) in [#​9965](https://redirect.github.com/vitest-dev/vitest/issues/9965) [<samp>(d3b7a)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/d3b7a40fa) - Disable colors if agent is detected - by [@​sheremet-va](https://redirect.github.com/sheremet-va) and [@​AriPerkkio](https://redirect.github.com/AriPerkkio) in [#​9851](https://redirect.github.com/vitest-dev/vitest/issues/9851) [<samp>(6f97b)</samp>](https://redirect.github.com/vitest-dev/vitest/commit/6f97b55dd) ##### [View changes on GitHub](https://redirect.github.com/vitest-dev/vitest/compare/v4.1.1...v4.1.2) </details> <details> <summary>webpro-nl/knip (knip)</summary> ### [`v6.0.6`](https://redirect.github.com/webpro-nl/knip/releases/tag/knip%406.0.6): Release 6.0.6 [Compare Source](https://redirect.github.com/webpro-nl/knip/compare/knip@6.0.5...knip@6.0.6) - Suppress issues initially to not overwhelm agent in mcp server ([`7793962`](https://redirect.github.com/webpro-nl/knip/commit/7793962c5)) - Auto-format ([`346247a`](https://redirect.github.com/webpro-nl/knip/commit/346247a70)) - Fix false positive unused deps when run from workspace dir (resolve [#​1642](https://redirect.github.com/webpro-nl/knip/issues/1642)) ([`95f4431`](https://redirect.github.com/webpro-nl/knip/commit/95f443195)) - Move from `convertPathsToAlias` → `compilePathMappings` (resolve [#​1641](https://redirect.github.com/webpro-nl/knip/issues/1641)) ([`ccc62d6`](https://redirect.github.com/webpro-nl/knip/commit/ccc62d684)) </details> <details> <summary>lucide-icons/lucide (lucide-react)</summary> ### [`v1.7.0`](https://redirect.github.com/lucide-icons/lucide/releases/tag/1.7.0): Version 1.7.0 [Compare Source](https://redirect.github.com/lucide-icons/lucide/compare/1.6.0...1.7.0) #### What's Changed - fix(lucide-react): Fix dynamic imports by [@​ericfennis](https://redirect.github.com/ericfennis) in [#​4210](https://redirect.github.com/lucide-icons/lucide/pull/4210) - feat(icons): added `map-pin-search` icon by [@​TonySullivan](https://redirect.github.com/TonySullivan) in [#​4125](https://redirect.github.com/lucide-icons/lucide/pull/4125) #### New Contributors - [@​TonySullivan](https://redirect.github.com/TonySullivan) made their first contribution in [#​4125](https://redirect.github.com/lucide-icons/lucide/pull/4125) **Full Changelog**: <lucide-icons/lucide@1.6.0...1.7.0> </details> <details> <summary>PostHog/posthog-js (posthog-js)</summary> ### [`v1.363.6`](https://redirect.github.com/PostHog/posthog-js/releases/tag/posthog-js%401.363.6) [Compare Source](https://redirect.github.com/PostHog/posthog-js/compare/posthog-js@1.363.5...posthog-js@1.363.6) #### 1.363.6 ##### Patch Changes - [#​3279](https://redirect.github.com/PostHog/posthog-js/pull/3279) [`32edaad`](https://redirect.github.com/PostHog/posthog-js/commit/32edaadd509e32a3a679142ccb704fd9e404d1a2) Thanks [@​pauldambra](https://redirect.github.com/pauldambra)! - Bump [@​posthog/rrweb](https://redirect.github.com/posthog/rrweb) packages to 0.0.51, which includes: - [PostHog/posthog-rrweb#145](https://redirect.github.com/PostHog/posthog-rrweb/issues/145): fix: handle cross-origin iframe errors during stop handler cleanup - [PostHog/posthog-rrweb#148](https://redirect.github.com/PostHog/posthog-rrweb/issues/148): fix: mask textarea innerText mutations - [PostHog/posthog-rrweb#150](https://redirect.github.com/PostHog/posthog-rrweb/issues/150): fix: guard WebGLRenderingContext access for iOS compatibility - [PostHog/posthog-rrweb#151](https://redirect.github.com/PostHog/posthog-rrweb/issues/151): refactor: extract slimDOMDefaults into shared function - [PostHog/posthog-rrweb#152](https://redirect.github.com/PostHog/posthog-rrweb/issues/152): fix: improve nested CSS rule handling - [PostHog/posthog-rrweb#153](https://redirect.github.com/PostHog/posthog-rrweb/issues/153): fix: allow clearing adopted stylesheets with empty strings - [PostHog/posthog-rrweb#154](https://redirect.github.com/PostHog/posthog-rrweb/issues/154): fix: prevent object reference mutation breaking remote CSS replay - [PostHog/posthog-rrweb#156](https://redirect.github.com/PostHog/posthog-rrweb/issues/156): fix: catch all SecurityError variants in stop handler cleanup (2026-03-26) - Updated dependencies \[]: - [@​posthog/types](https://redirect.github.com/posthog/types)@​1.363.6 </details> <details> <summary>PostHog/posthog-js (posthog-node)</summary> ### [`v5.28.6`](https://redirect.github.com/PostHog/posthog-js/blob/HEAD/packages/node/CHANGELOG.md#5286) [Compare Source](https://redirect.github.com/PostHog/posthog-js/compare/posthog-node@5.28.5...posthog-node@5.28.6) ##### Patch Changes - [#​3282](https://redirect.github.com/PostHog/posthog-js/pull/3282) [`5784dca`](https://redirect.github.com/PostHog/posthog-js/commit/5784dcaeb71f7e67d9c9df28f116886a573d19df) Thanks [@​marandaneto](https://redirect.github.com/marandaneto)! - fix: captureException now uses distinctId from request context (2026-03-26) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/doxynix/doxynix).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
stopRecord()with try-catch to prevent cross-origin iframeSecurityErrors from crashing the entire stop processstopRecord()and prevented subsequent handlers from cleaning up"from accessing a cross-origin frame"and"Blocked a frame with origin"in the message)Test plan
pnpm build:all)🤖 Generated with Claude Code