Skip to content

fix: rrweb recorder may throw error when stopping recording after an iframe becomes cross-origin #1695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

YunFeng0817
Copy link
Member

@YunFeng0817 YunFeng0817 commented May 27, 2025

The CI failure can be solved by #1696

@Copilot Copilot AI review requested due to automatic review settings May 27, 2025 21:07
Copy link

changeset-bot bot commented May 27, 2025

🦋 Changeset detected

Latest commit: 3528d2d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
rrweb Patch
rrweb-snapshot Patch
rrdom Patch
rrdom-nodejs Patch
rrweb-player Patch
@rrweb/all Patch
@rrweb/replay Patch
@rrweb/record Patch
@rrweb/types Patch
@rrweb/packer Patch
@rrweb/utils Patch
@rrweb/web-extension Patch
rrvideo Patch
@rrweb/rrweb-plugin-console-record Patch
@rrweb/rrweb-plugin-console-replay Patch
@rrweb/rrweb-plugin-sequential-id-record Patch
@rrweb/rrweb-plugin-sequential-id-replay Patch
@rrweb/rrweb-plugin-canvas-webrtc-record Patch
@rrweb/rrweb-plugin-canvas-webrtc-replay Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where the rrweb recorder throws an error when stopping recording after an iframe becomes cross-origin. The changes wrap the stop handlers in a try/catch block to suppress expected cross-origin errors and a new test case has been added to validate the fix.

  • Wraps each handler call in a try/catch to prevent cross-origin access errors.
  • Adds a new test to verify that stopping the recorder after setting an iframe’s src to a cross-origin URL does not throw an error.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/rrweb/test/record.test.ts Adds a test ensuring that stopping recording after an iframe becomes cross-origin does not throw an error.
packages/rrweb/src/record/index.ts Wraps handler calls in a try/catch to safely ignore expected cross-origin errors.
Comments suppressed due to low confidence (1)

packages/rrweb/test/record.test.ts:1002

  • [nitpick] Consider using a more robust waiting mechanism such as an event listener or polling for a condition instead of a fixed timeout to avoid potential flakiness in tests.
await new Promise((resolve) => setTimeout(resolve, 1000));

@YunFeng0817 YunFeng0817 requested a review from Copilot May 27, 2025 21:21
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR prevents errors when stopping the rrweb recorder after an iframe changes to cross-origin, adds a test for this scenario, and bumps the patch version.

  • Add a functional test to verify no exception is thrown when stopping recording post cross-origin iframe navigation.
  • Wrap each stop-record handler in try/catch and ignore known cross-origin access errors.
  • Update the changeset to publish a patch release.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/rrweb/test/record.test.ts Added test ensuring stopRecord doesn’t throw after iframe src changes to cross-origin
packages/rrweb/src/record/index.ts Wrapped cleanup handlers in try/catch and suppress cross-origin frame errors
.changeset/nervous-actors-jam.md Bumped patch version with PR description

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.

1 participant