You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding scriptTag.crossOrigin = "" here might be worthwhile. But I know little about this stuff so I'll just share what led me to it.
In our app we log all uncaught exceptions i.e. those triggering the window error or unhandledrejection events. We recently started getting error events that just contained the message Script error.. These are the only errors we've seen without a stacktrace. Fortunately we were able to reproduce locally and tracked it down to rrweb-io/rrweb#1444.
When an error occurs in a script, loaded from a different origin, the details of the error are not reported to prevent leaking information (see bug 363897). Instead the error reported is "Script error." This behavior can be overridden in some browsers using the crossorigin attribute on <script> and having the server send the appropriate CORS HTTP response headers.
It would great to get a useful error when rrweb or other dependencies of PostHog throw an exception, so we can narrow down for example whether it's our app (high priority) or product analytics (low). Access-Control-Allow-Origin: * is already sent in the HTTP responses so I think all that's needed is adding .crossOrigin = "" to loadScript above, as well as the JS snippet.
I don't know if there are any downsides, feel free to close if this isn't workable. From a quick search it looks like it might also solve #976.
The text was updated successfully, but these errors were encountered:
loadScript
is used to load recorder.js, surveys.js, exception-autocapture.js and toolbar.js:posthog-js/src/utils/index.ts
Lines 462 to 487 in fd0f19e
Adding
scriptTag.crossOrigin = ""
here might be worthwhile. But I know little about this stuff so I'll just share what led me to it.In our app we log all uncaught exceptions i.e. those triggering the window
error
orunhandledrejection
events. We recently started gettingerror
events that just contained the messageScript error.
. These are the only errors we've seen without a stacktrace. Fortunately we were able to reproduce locally and tracked it down to rrweb-io/rrweb#1444.I believe the errors are opaque due to cross-origin security restrictions. Per MDN per https://stackoverflow.com/questions/41069330/with-script-crossorigin-anonymous-why-is-a-script-blocked-by-cors-policy/71829749#71829749:
See also https://stackoverflow.com/questions/5913978/cryptic-script-error-reported-in-javascript-in-chrome-and-firefox/7778424#7778424.
It would great to get a useful error when
rrweb
or other dependencies of PostHog throw an exception, so we can narrow down for example whether it's our app (high priority) or product analytics (low).Access-Control-Allow-Origin: *
is already sent in the HTTP responses so I think all that's needed is adding.crossOrigin = ""
toloadScript
above, as well as the JS snippet.I don't know if there are any downsides, feel free to close if this isn't workable. From a quick search it looks like it might also solve #976.
The text was updated successfully, but these errors were encountered: