Skip to content

Commit 4309de7

Browse files
gnpaoneeoghanmurraykevinatownJuice10pauldambra
authored
Sync from source repo (#19)
* Fix up the 'should replace the existing DOM nodes on iframe navigation with `isAttachIframe`' test (rrweb-io#1636) - it was working for me when the test was run in isolation (`-t` option), but when the entire cross-origin-iframes test was run, the change of iframe contents didn't seem to happen in time * [chore]: Update actions/upload-artifact to v4 (rrweb-io#1643) * update actions/upload-artifact to v4 --------- Co-authored-by: Eoghan Murray <[email protected]> * Fix a code path where masking could be skipped on textareas (rrweb-io#1599) * Fixes rrweb-io#1596 * [chore] Cache yarn packages for CI (rrweb-io#1646) * [chore] Cache yarn packages for CI * Cache yarn in release.yml * [chore] Update deprecated download artifact on CI (rrweb-io#1647) * I'm merging even though ESLint is stlll failing in Github Actions as I believe it's running actions _without_ this PR applied yet * Fix env puppeteer error in cross-origin-iframes.test.ts (rrweb-io#1629) * chore(ci): track bundle size (rrweb-io#1630) * chore(ci): track bundle size --------- Co-authored-by: pauldambra <[email protected]> * Fix adapt css with split (rrweb-io#1600) Fix for rrweb-io#1575 where postcss was raising an exception * adapt the entire CSS as a whole in one pass with postcss, rather than adapting each split part separately * break up the postcss output again and assign to individual text nodes (kind of inverse of splitCssText at record side) * impose an upper bound of 30 iterations on the substring searches to preempt possible pathological behavior * add tests to demonstrate the scenario and prevent regression More technical details: * Fix algorithm; checks against `ix_end` within loop were incorrect when `ix_start` was bigger than zero. * Fix that length check against wrong array was causing 'should record style mutations with multiple child nodes and replay them correctly' test to fail. Note on last point: I haven't looked into things more deeply than that the test was complaining about missing .length after `replayer.pause(1000);` * Warn instead of fail on exceptions thrown from postcss (rrweb-io#1580) * postcss was introduced in rrweb-io#1458 for use within adaptCssForReplay * rrweb-io#1600 fixes the main case where invalid css could be introduced when if valid css from the output of `sheet.cssRules` was split according to how it was split across text nodes of the <style> * the guard introduced here is still useful as we likely in future will switch to capturing the raw stylesheet contents (both <style> and <link>), at which point we will be much less confident of getting valid css * Fix splitCssText again (rrweb-io#1640) Fixes a browser 'lock up' at record time due to a presence of large amounts of css in <style> elements, which are split over multiple text nodes, which triggers the new code added in rrweb-io#1437 (see that PR for full explanation of why this all exists). rrweb-io#1437 was not written with performance in mind as it was believed to be an edge case, but things like Grammarly browser extension (rrweb-io#1603) among other scenarios were triggering pathological behavior, some of which was solved in rrweb-io#1615. See also rrweb-io#1640 (comment) for further discussion. * Fix the case when there are multiple matches and we end up not finding a unique one - just go with the best guess when there are many splits by looking at the previous chunk's size * Also add '0px' -> '0' stylesheet normalization, which also fixes the sample problem in a different way * Add new test and modify it so that it can trigger a failure in the absence of the '0px' normalization; there may be other unknown ways of triggering a similar bug, so ensure that the primary 'best guess' method doesn't suffer a regression * Leverage the 'best guess' method so that we can quit after 100 iterations trying to find a unique substring; hopefully this bit along with the `iterLimit` already added will prevent any future pathological cases. Failing example extracted from large files identified by Paul D'Ambra (Posthog) ... see comment from MartinWorkfully: PostHog/posthog-js#1668 * fix: move patch function into utils to improve bundling (rrweb-io#1631) * fix: move patch function into utils to improve bundling --------- Co-authored-by: pauldambra <[email protected]> Co-authored-by: Justin Halsall <[email protected]> --------- Co-authored-by: Eoghan Murray <[email protected]> Co-authored-by: Kevin Townsend <[email protected]> Co-authored-by: Justin Halsall <[email protected]> Co-authored-by: Paul D'Ambra <[email protected]> Co-authored-by: pauldambra <[email protected]> Co-authored-by: John Henry Gunther <[email protected]>
1 parent 9e238e6 commit 4309de7

26 files changed

+393
-87
lines changed

.changeset/angry-turtles-provide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"rrweb-snapshot": patch
3+
---
4+
5+
Handle exceptions thrown from postcss when calling adaptCssForReplay
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"rrweb-snapshot": patch
3+
"rrweb": patch
4+
---
5+
6+
Improve performance of splitCssText for <style> elements with large css content - see #1603

.changeset/fix-adapt-css.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"rrweb": patch
3+
"rrweb-snapshot": patch
4+
---
5+
6+
#1575 Fix that postcss could fall over when trying to process css content split arbitrarily

.changeset/itchy-tables-compete.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@rrweb/rrweb-plugin-console-record": patch
3+
"@rrweb/record": patch
4+
"rrweb": patch
5+
"@rrweb/utils": patch
6+
---
7+
8+
Move patch function into @rrweb/utils to improve bundling

.changeset/shy-countries-rhyme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/workflows/ci-cd.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ jobs:
3434
# run: PUPPETEER_EXECUTABLE_PATH=${{ steps.setup-chrome.outputs.chrome-path }} PUPPETEER_HEADLESS=true xvfb-run --server-args="-screen 0 1920x1080x24" yarn test
3535
run: PUPPETEER_HEADLESS=true xvfb-run --server-args="-screen 0 1920x1080x24" yarn test
3636

37+
- name: Check bundle sizes
38+
uses: preactjs/compressed-size-action@v2
39+
with:
40+
install-script: "yarn install --frozen-lockfile"
41+
build-script: "build:all"
42+
compression: "none"
43+
pattern: "**/dist/*.{js,cjs,mjs,css}"
44+
3745
- name: Upload diff images to GitHub
3846
uses: actions/upload-artifact@v4
3947
if: failure()

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ dist
3535
# for vite
3636
vite.config.js.timestamp-*
3737
vite.config.ts.timestamp-*
38+
39+
# bundle analysis files
40+
*-bundle-analysis.html

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"markdownlint": "^0.25.1",
4343
"markdownlint-cli": "^0.31.1",
4444
"prettier": "2.8.4",
45+
"rollup-plugin-visualizer": "^5.12.0",
4546
"turbo": "^2.0.4",
4647
"typescript": "^5.4.5"
4748
},

packages/plugins/rrweb-plugin-console-record/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"puppeteer": "^20.9.0"
5858
},
5959
"peerDependencies": {
60-
"rrweb": "^2.0.1-alpha.20"
60+
"rrweb": "^2.0.1-alpha.20",
61+
"@rrweb/utils": "^2.0.1-alpha.20"
6162
}
6263
}

packages/plugins/rrweb-plugin-console-record/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { listenerHandler, RecordPlugin, IWindow } from '@rrweb/types';
2-
import { utils } from 'rrweb';
2+
import { patch } from '@rrweb/utils';
33
import { ErrorStackParser, StackFrame } from './error-stack-parser';
44
import { stringify } from './stringify';
55

@@ -183,7 +183,7 @@ function initLogObserver(
183183
};
184184
}
185185
// replace the logger.{level}. return a restore function
186-
return utils.patch(
186+
return patch(
187187
_logger,
188188
level,
189189
(original: (...args: Array<unknown>) => void) => {

0 commit comments

Comments
 (0)