Repository navigation
fix(record): resync sends only the rules the replayer is missing - #43
Merged
Merged
Conversation
Track the replayer's copy of each stylesheet as the live CSSRule objects it was recorded from, and diff by identity on resync instead of replacing the whole sheet whenever the rule count changed. A missed insert now costs one rule, appended or mid-sheet, including on pages that keep displacing the insertRule patch after we stop repatching. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mayberryzane
marked this pull request as ready for review
October 14, 2026 17:57
RobertPakkoLD
approved these changes
Oct 14, 2026
mayberryzane
added a commit
to launchdarkly/observability-sdk
that referenced
this pull request
Oct 14, 2026
…sing Bumps rrweb to pick up launchdarkly/rrweb#43. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mayberryzane
added a commit
to launchdarkly/observability-sdk
that referenced
this pull request
Oct 14, 2026
…sing (#831) Bumps the rrweb submodule to pick up [launchdarkly/rrweb#43](launchdarkly/rrweb#43). When recording recovers CSS-in-JS rules after another script displaced its `insertRule` patch, it now sends only the rules the replayer is missing instead of re-sending the whole stylesheet (the behaviour #825 shipped). Pages that keep displacing the patch no longer re-upload every growing sheet on each resync. The submodule points at the #43 merge commit, [964641c](launchdarkly/rrweb@964641cbbe), on rrweb `main`. The `@launchdarkly/o11y` suite passes against this commit (509 tests), including the stylesheet resync test from #829. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > Updates the **`rrweb` git submodule** to include [launchdarkly/rrweb#43](launchdarkly/rrweb#43), changing how **stylesheet resync** works after another script restores a pristine `CSSStyleSheet.prototype.insertRule` and displaces the recorder’s patch. > > On recovery, recording now emits **only the CSS rules the replayer is missing** instead of re-sending the **entire** stylesheet (the behavior introduced in #825). That cuts repeated full-sheet uploads on pages that keep displacing the patch as CSS-in-JS sheets grow. > > No `@launchdarkly/o11y` source changes in this PR—the behavioral fix lives in the fork; existing coverage includes the stylesheet resync test from #829. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit fed55ae. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #42. When the
insertRulepatch has been displaced, the resync now sends the replayer only the rules it is missing instead of replacing the whole sheet.#42 fixed correctness for libraries that insert mid-sheet, but at a cost: any sheet whose rule count changed was deleted and re-sent in full. That also hit libraries that only append (emotion), which the earlier tail re-send handled correctly. And on a page that keeps displacing the patch after we stop repatching, every growing sheet was re-sent in full on each resync tick.
The recorder now keeps, per sheet, the top-level rules the replayer holds, as the live
CSSRuleobjects they were recorded from. Reported inserts and deletes update that list exactly asapplyStyleSheetRuleapplies them (an insert index clamped to the sheet length, an out-of-range delete ignored). CSSOM rule objects keep their identity as rules are inserted around them, so on resync a comparison againstsheet.cssRulesgives:These are sent as two events, because the replayer applies an event's adds before its removes. A sheet first seen while capture was already broken is still replaced in full, since there is nothing to compare against. Healthy ticks skip a sheet whose count matches, as before.
New tests pin the cost as well as the result: a missed append, a missed mid-sheet insert, a missed delete plus insert, and a patch displaced eight times (past the repatch limit) each send exactly the changed rules, and the sheet rebuilt from the events matches the live one. All four fail against the previous commit.
test/record,test/replayandtest/replayer.test.tspass locally (242 passed, 3 skipped).🤖 Generated with Claude Code
Note
Overview
When the CSSOM
insertRule/deleteRulepatch is displaced, stylesheet resync no longer wipes and re-sends entire sheets on every tick. The recorder now mirrors what the replayer holds: per-sheet ordered lists of liveCSSRuleobjects, updated on each reported insert/delete the same wayapplyStyleSheetRuleapplies them.On resync,
syncReplayerCopydiffs that list againstsheet.cssRules—removes stale or out-of-order entries (high index first), then adds missing rules at their live indices (low first), split across two events because adds run before removes. FullreplaceReplayerCopyis kept only when a sheet is first seen while capture was already broken.Tests assert replay fidelity and incremental event cost: missed mid-sheet insert, append-only (emotion-style), missed delete+insert, and repeated patch displacement each emit only the changed rules, not the whole sheet again.
Reviewed by Cursor Bugbot for commit 953b285. Bugbot is set up for automated code reviews on this repo. Configure here.