Search code examples
javascriptreactjsfacebooknext.jssentry

JSON Parse error: Unrecognized token '!' - error caught by Sentry


The error in the title is caught by Sentry (an error tracking tool). Below is a screenshot from Sentry - showing the stack trace.

sentry screenshot

Note: the script /en_US/iab.autofill.payment.js where handleMessage is located is loaded from Facebook (link here), and I couldn't find this script in the javascript bundle, nor anything related to it. I assume it's loaded by a 3rd party script - I'm using Google Tag Manager (which is also loading Facebook Pixel), Segment (loading Hotjar and Mixpanel), and Snapchat. The error started to appear without any changes in these scripts or the services that they're sending data to.

Note 2: It seems that the error is triggered quite often, about 10-15% of the time. I tried to reproduce it but given that it's a handled error, it doesn't show in the dev console.

Any direction on where to look would be much appreciated.


Solution

  • Apparently, the issue went away after a couple of weeks without changing anything on my side.