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

Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node' #678

Open
valgen opened this issue Mar 10, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@valgen
Copy link

valgen commented Mar 10, 2024

Expected Behavior

Normally there shouldn't be any console errors.

Current Behavior

Occasionally we get this console error:

analytics-browser-2.4.0-min.js.gz:1 Uncaught (in promise) TypeError: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'.
    at analytics-browser-2.4.0-min.js.gz:1:55953
    at analytics-browser-2.4.0-min.js.gz:1:2282
    at Object.next (analytics-browser-2.4.0-min.js.gz:1:2387)
    at analytics-browser-2.4.0-min.js.gz:1:1303
    at new Promise (<anonymous>)
    at r (analytics-browser-2.4.0-min.js.gz:1:1048)
    at Object.setup (analytics-browser-2.4.0-min.js.gz:1:55078)
    at e.<anonymous> (analytics-browser-2.4.0-min.js.gz:1:6781)
    at analytics-browser-2.4.0-min.js.gz:1:2282
    at Object.next (analytics-browser-2.4.0-min.js.gz:1:2387)

Possible Solution

The error suggests a race condition as highlighted here: https://stackoverflow.com/questions/40398054/observe-on-mutationobserver-parameter-1-is-not-of-type-node

Steps to Reproduce

Unfortunately it's not reproducible on demand. It happens randomly.

This is the code I use:

amplitude.init(amplitudeApiKey, {
    defaultTracking: {
        pageViews: false
    }
}).promise.then(function () {

    var amplitudeProperties = {
        'p1': p1,
        'p2': p2
    };

    amplitude.track('page_viewed', amplitudeProperties);

    amplitude.flush();
});

Environment

  • Library: "amplitude-ts/2.4.0"
  • Installation Method: via JS using <script>
  • Browser and Version: Chrome version 122.0.6261.95 (Official Build) (64-bit)
@valgen valgen added the bug Something isn't working label Mar 10, 2024
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

1 participant