Skip to content

Commit

Permalink
Fix a replay issue where the 500ms timeout was being hit
Browse files Browse the repository at this point in the history
 - 3.7K nodes being inserted, with ~200 <tr>s as the root nodes making up the `resolveTrees`
 - each table row was dependent on the next, resulting in cascading failures; 19K repopulation of queue due to `nextNotInDOM`, and an additional cascading 350K repopulation of queue due to missing parent nodes
  • Loading branch information
eoghanmurray committed Oct 9, 2023
1 parent 297104c commit 14dadb4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/rrweb/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ export function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {
queueNodeMap[m.node.id] = nodeInTree;
return nodeInTree;
};
const rootNexts = new Set<number>();

const queueNodeTrees: ResolveTree[] = [];
for (const mutation of queue) {
Expand All @@ -368,7 +369,16 @@ export function queueToResolveTrees(queue: addedNodeMutation[]): ResolveTree[] {
parentInTree.children.push(putIntoMap(mutation, parentInTree));
continue;
}
queueNodeTrees.push(putIntoMap(mutation, null));
if (nextId) {
rootNexts.add(nextId);
}
const rootTree = putIntoMap(mutation, null);
if (rootNexts.has(mutation.node.id)) {
// some existing tree can't be inserted until this one is (nextNotInDOM check)
queueNodeTrees.unshift(rootTree);
} else {
queueNodeTrees.push(rootTree);
}
}

return queueNodeTrees;
Expand Down

0 comments on commit 14dadb4

Please sign in to comment.