Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Failed to execute 'matches' on 'Element': The provided selector is empty. #804

Closed
priemskiyyy opened this issue Jul 8, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@priemskiyyy
Copy link

Expected Behavior

No errors should occur in this section of the code.

Current Behavior

A few days ago, we noticed a significant increase in error events in Sentry originating from rrweb package. Previously, there were no issues. The stack trace indicates that the error occurs in the following part of rrweb code:

    if (blockSelector) {
        if (el.matches(blockSelector))
            return true;
        if (checkAncestors && el.closest(blockSelector) !== null)
            return true;
    } 

Additionally, sometimes we encounter this error:

SyntaxError: '' is not a valid selector.

Possible Solution

Extra checks in the highlighted part of the code to ensure blockSelector is valid before using it?

Steps to Reproduce

  1. Install @amplitude/analytics-browser, @amplitude/plugin-session-replay-browser
  2. Initialize Amplitude and add the session replay plugin
  3. Observe issues in Sentry

Environment

  • @amplitude/analytics-browser: 2.4.1
  • @amplitude/plugin-session-replay-browser: 1.5.1
  • next: 14.2.4
  • node: >= 18.20.0
  • Installation Method: pnpm
  • Browser and Version: n/a
@priemskiyyy priemskiyyy added the bug Something isn't working label Jul 8, 2024
@lewgordon-amplitude
Copy link

Hi @priemskiyyy ! Thanks for opening this. In a more recent version we pre-filter invalid selector so that rrweb won't hit errors. This comes with the side effect that this may not block as expected, but incur less errors. Does this work for you or would you want some other precheck mechanism (e.g. fast fail on startup)?

@lewgordon-amplitude lewgordon-amplitude self-assigned this Jul 8, 2024
@priemskiyyy
Copy link
Author

Hey @lewgordon-amplitude ,
Sorry for the delay. I tested the latest version, and it works fine. Thanks for addressing the issue and for your support!

@lewgordon-amplitude
Copy link

Awesome, glad to hear!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants