Skip to content

CustomEvent trigger can result in infinite loop #1015

@snake14

Description

@snake14

A customer was seeing an error stating Uncaught RangeError: Maximum call stack size exceeded in the JS console while matomo.js was loading. It was found that window.MatomoTagManager.dataLayer.events contained a very large number of identical entries for {event: 'mtm.CustomEvent', mtm.CustomEventMatch: 'mtm.CustomEvent'}. There was apparently a trigger which was triggering on events named mtm.CustomEvent. Searching the JSON of the container, there was no trigger checking for eventName equal to mtm.CustomEvent. However, there was a DataLayer variable for the dataLayer event property and a CustomEvent trigger was watching that.

As a workaround, the DataLayer variable can be updated to automatically convert the value if it equals mtm.CustomEvent. Here's a tested example:

Image

Problem:

  • CustomEvent triggers automatically push an event onto the dataLayer when the eventName matches which can cause a circular reference if the name equals mtm.CustomEvent.

Solution:

  • The CustomEvent trigger shouldn't allow the field for the name of the event to equal mtm.CustomEvent. The UI should show a validation error.
  • There should also be a check in the JS to prevent events named mtm.CustomEvent from triggering an event and being pushing onto the dataLayer. This is necessary for existing setups and because UI validation can't prevent variables from having the value of mtm.CustomEvent at runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions