rrweb-io / rrweb

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

[Bug]: The message listener for iframe getting duplicated, if started recording after stop recording. #1590

Open chetan-187 opened 1 week ago

chetan-187 commented 1 week ago

Preflight Checklist

What package is this bug report for?

rrweb

Version

rrweb@2.0.0-alpha.17

Expected Behavior

The message listeners should get cleared, if the recording is started after stopping. Since all observers and listeners gets cleared

Actual Behavior

The message listener of iframe gets added after stop and recording again.

Steps to Reproduce

  1. Call record function of rrweb, with recordCrossOrigin: true option
  2. Stop the recording by calling function returned by record function
  3. Call record function again
  4. Look at the global listeners, the message listener from iframe-manager gets added everytime.

Testcase Gist URL

No response

Additional Information

No response

chetan-187 commented 1 week ago

Can this be solved by making IframeManager a singleton class and removing the message handler before initializing new one?