Skip to content

The posthog-js library is throwing error, when user is iddle #2533

@lukasbicus

Description

@lukasbicus

Bug description

Our Sentry reported over 170 errors during the last month, with this error thrown:

SecurityError: Failed to read a named property 'removeEventListener' from 'Window': Blocked a frame with origin "https://app.tradespace.io" from accessing a cross-origin frame.
    at h (../../../node_modules/.pnpm/@rrweb+record@2.0.0-alpha.17_patch_hash=4a974d451d029e3ef6c302f641dfaf41fb0881146b6d5198ccdbe8d50776b64f/node_modules/@rrweb/record/dist/record.js:3615:1)
    at forEach (../../../node_modules/.pnpm/@rrweb+record@2.0.0-alpha.17_patch_hash=4a974d451d029e3ef6c302f641dfaf41fb0881146b6d5198ccdbe8d50776b64f/node_modules/@rrweb/record/dist/record.js:5571:27)
    at Array.forEach (<anonymous>)
    at call (../../../node_modules/.pnpm/@rrweb+record@2.0.0-alpha.17_patch_hash=4a974d451d029e3ef6c302f641dfaf41fb0881146b6d5198ccdbe8d50776b64f/node_modules/@rrweb/record/dist/record.js:5571:14)
    at LazyLoadedSessionRecording.stop (../src/extensions/replay/external/lazy-loaded-session-recorder.ts:791:9)
    at this._onSessionIdleResetForcedListener (../src/extensions/replay/external/lazy-loaded-session-recorder.ts:704:22)
    at SimpleEventEmitter.emit (../../../node_modules/posthog-js/src/utils/simple-event-emitter.ts:21:13)
    at this._enforceIdleTimeout (../../../node_modules/posthog-js/src/sessionid.ts:329:36)
    at sentryWrapped (../../../node_modules/@sentry/browser/src/helpers.ts:117:17)

Please describe.

How to reproduce

  1. The users were idle for a long period of time

Related sub-libraries

  • All of them
  • posthog-js (web)
  • posthog-js-lite (web lite)
  • posthog-node
  • posthog-react-native
  • @posthog/react
  • @posthog/ai
  • @posthog/nextjs-config

Additional context

The bug seems to happen to me, originating in the @rrweb/record@2.0.0-alpha.17 / using the @rrweb/record@2.0.0-alpha.17 in Posthog.

Updating to @rrweb/record@2.0.0-alpha.18 may help.

Any advice, how can this be fixed in our repository?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions