I'm getting a strange error in a Rails app
Uncaught SyntaxError: Unexpected token < in JSON at position 0 new:7
The browser console is showing this error as being raised by code injected by newrelic ruby agent.
Line 7: <script>(window.NREUM||(NREUM={})).loader_config={xpid:"xxxxxxx"};window.NREUM||(NREUM={}),__nr_require.........#and so on
The newrelic code appears on every page, but the error only seems to occur on one page.
This page is consuming a couple of internal JSON APIs. One creates a remote Select2 dropdown from a countries json feed, and another renders a Mapbox map from the same feed of countries.
The API is formatted as GeoJSON (with no unexpected <
tokens!)
[
{
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[0,0]
},
"properties": {
# some attributes
}
}
]
Why is the NewRelic code interacting with JSON? And what is a good strategy or approach for debugging this? As the error is being raised by code injected by the Newrelic Ruby Agent, I'm unclear where to begin looking to resolve this.
I can't speak too this situation specifically, but historically I have noticed this type of error happens when a resource is not found, and an HTML page is returned in place of the resource (a 404 page or something similar).