-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
base: master
Are you sure you want to change the base?
Conversation
…iframe becomes cross-origin
🦋 Changeset detectedLatest commit: 3528d2d The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 packages
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 |
There was a problem hiding this 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));
There was a problem hiding this 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 |
The CI failure can be solved by #1696