rrweb icon indicating copy to clipboard operation
rrweb copied to clipboard

[Bug]: Uncaught SyntaxError: Regular expression too large

Open mrfullset opened this issue 10 months ago • 5 comments

Preflight Checklist

  • [X] I have searched the issue tracker for a bug report that matches the one I want to file, without success.

What package is this bug report for?

rrweb

Version

v2.0.0-alpha.13

Expected Behavior

Live mode replay starts

Actual Behavior

rrweb fails with an error in a console: Uncaught SyntaxError: Invalid regular expression: (huge CSS contents) Regular expression too large

Steps to Reproduce

rrweb.record({
        emit(event) {
          // send via websocket
        },
        recordCanvas: true,
        dataURLOptions: {
          type: 'image/webp',
          quality: 0.6,
        },
      });
rrweb.Replayer([],
        { root: this.$refs.container,
          liveMode: true,
          UNSAFE_replayCanvas: true,
          mouseTail: {
            strokeStyle: "#d0d4e1"
          }
        })

Testcase Gist URL

No response

Additional Information

The same code as in "Steps to Reproduce" section worked with v1.1.3. CSS inside of a regex are generated by Tailwind.

mrfullset avatar Apr 24 '24 14:04 mrfullset

We are also seeing this.

dobrynin avatar May 13 '24 20:05 dobrynin

It seems to be coming from https://github.com/rrweb-io/rrweb/blob/26c331b3b7e1a45091904fd1a6a875e16c9b777f/packages/rrweb-snapshot/src/rebuild.ts#L112-L118

dobrynin avatar May 13 '24 20:05 dobrynin

Yes I am also experiencing the same issue with my React Webapp. Is there any workaround?

image

priyankblitzz avatar May 16 '24 06:05 priyankblitzz

@priyankblitzz we didn't have any workaround other than rolling back rrweb to alpha.11

colingm avatar May 16 '24 12:05 colingm

I'm not sure what has changed such that it's now generating a bigger CSS regex on the first selectorMatcher, as #1431 didn't modify that. Does anyone have a test website that reliably generates the issue? Is that <SVG embedded in CSS or is it in the document and somehow mistakenly going through the adaptCssForReplay function?

There's also #1458 which makes improvements and might be able to fix it although not quite currently ready for merge.

eoghanmurray avatar May 16 '24 13:05 eoghanmurray

Could you guys review or apply #1481 to verify that it fixes it?

eoghanmurray avatar May 21 '24 09:05 eoghanmurray

just tried the latest version(alpha 14) in my web app and it is working fine now. The issue is resolved for me now. Thank you so much for taking care of the issue.

priyankblitzz avatar May 23 '24 05:05 priyankblitzz