Skip to content

Commit

Permalink
Return early for child same origin frames
Browse files Browse the repository at this point in the history
If we have cross origin record turned on but we are in a child
frame that has the same origin as its parent we end up in sort
of an inefficient state. We will start the recording, record
mutations, but then never actually emit them anywhere since
inEmittingFrame and passEmitsToParent are both false. This
is a waste of resources and we might as well just never start
the recording.
  • Loading branch information
colingm committed May 1, 2024
1 parent f1e6a51 commit 82fc65d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/rrweb/src/record/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ function record<T = eventWithTime>(
if (inEmittingFrame && !emit) {
throw new Error('emit function is required');
}
if (!inEmittingFrame && !passEmitsToParent) {
return () => {
/* no-op since in this case we don't need to record anything from this frame in particular */
};
}
// move departed options to new options
if (mousemoveWait !== undefined && sampling.mousemove === undefined) {
sampling.mousemove = mousemoveWait;
Expand Down

0 comments on commit 82fc65d

Please sign in to comment.