rrweb-io / rrweb

record and replay the web
https://www.rrweb.io/
MIT License
16.61k stars 1.42k forks source link

[Bug]: Stopping recording causes all insertRule hooks added after record start to drop #1518

Open eugene-chang-fs opened 3 months ago

eugene-chang-fs commented 3 months ago

Preflight Checklist

What package is this bug report for?

rrweb

Version

v1.1.3

Expected Behavior

Sentry/rrweb should not drop hooks on the prototypical chain (shown in demo under output).

See result without rrweb: https://imgur.com/C0veqB0

Actual Behavior

Sentry/rrweb does drop hooks installed.

See result with rrweb extension: https://imgur.com/a/DGIoUSv

Steps to Reproduce

As far as I'm aware, this happens to all versions.

Any hooks added to insertRule are dropped once rrweb stops recording.

  1. Start capturing
  2. Add a hook to CSSStyleSheet.prototype.insertRule
  3. Stop capturing
  4. Observe that hook added by step 2 is no longer in place

Expected/actual behaviors are two videos of a demo page (source: https://jsfiddle.net/pmd5L8v7/). Once hooked, adding a rule to change the color of the text snippet at the top should result in an output line, indicating that the hook worked. But in the result with rrweb, this behavior is absent, indicating that the hook was dropped.

Testcase Gist URL

No response

Additional Information

This was originally filed with sentry @ https://github.com/getsentry/sentry-javascript/issues/11837 but was suggested to post the issue here.