Internet Explorer 11 crashes when JSON.stringify is called on an HTMLFormElement that contains duplicate named inputs. This is particularly concerning because radio inputs will certainly have duplicate names.

In these simplified recreation steps, we can reliably crash Internet Explorer 11 (11.103.10586) by passing a simple HTMLFormElement into JSON.stringify. This is impacting some TrackJS customers, and the Tracker JavaScript Agent itself, which calls JSON.stringify when attempting to serialize console arguments.

<!DOCTYPE html>
<html>
  <head></head>
  <body>
    <h1>IE11 Freezes on JSON.Stringify</h1>

    <form id="my-form">
      <input name="emailoptin"  />
      <input name="emailoptin"  />
    </form>

    <button id="freeze-me" onclick="JSON.stringify(document.getElementById('my-form'))">Freeze Me</button>

  </body>

</html>

Solution

We are considering alternatives to avoid this bug, but in the meantime you can avoid this issue by adding a custom serializer to your TrackJS configuration that does not use JSON.stringify. For example:

window._trackJs = {
  token: 'YOUR_TOKEN',
  serialize: function (item) {
    return ""+item;
  }
};