0

Sentry is notifying me of errors, with a stacktrace that starts with at global code (https://www.<mydomain>.com:1:49)

In my header tag I have several scripts.

How can I know which script tag, and which line of it, is causing the error?

Vic Seedoubleyew
  • 9,888
  • 6
  • 55
  • 76
  • You may need to upload your sourcemaps to Sentry. – IVO GELOV Mar 16 '22 at 18:51
  • Thanks for your comment. Since it says "global code", doesn't it mean that it's supposed to come from an inline script, as opposed to a script loaded with a "src" attribute? – Vic Seedoubleyew Mar 21 '22 at 17:09
  • `Global code` usually means the statement is not part of a function. – IVO GELOV Mar 22 '22 at 11:17
  • Thanks, that's very interesting to know. That is more or less the essence of my question. Does the fact that between parentheses it is my home page's URL, and not a script URL, mean that it comes from inline code, and not a loaded script, or not? – Vic Seedoubleyew Mar 24 '22 at 15:07
  • No, there is no such distinction - it just means that the code is run in the topmost "scope" rather than inside a function (other scope). The only way to distinguish the source file I can think of, is by throwing an exception and inspecting the stacktrace. – IVO GELOV Mar 25 '22 at 08:16
  • Thanks a lot for your help. I am confused as to your suggestion to throw an exception. From the stacktrace I get through Sentry, it is already an exception. You mean reproduce it locally? I can't do that, I have no idea what caused the problem. – Vic Seedoubleyew Mar 29 '22 at 09:50
  • Have you uploaded sourcemaps in Sentry? If yes - then the error might be coming from a browser extension rather than your code. If not - sourcemaps will allow you to see the original line in the source code where the error occurred. – IVO GELOV Mar 30 '22 at 10:42
  • Thanks for the insights. What if the error was caused by third party code, for example the Drift widget? I guess uploading my source files wouldn't change much, would it? – Vic Seedoubleyew Apr 05 '22 at 15:36
  • Obviously, your sourcemaps cover only your own code - third-party code will be minified. And if the widget runs in IFRAME - I have some doubts whether Sentry will catch its errors. – IVO GELOV Apr 06 '22 at 06:52
  • Thanks a lot. It's funny you'd mention iframes, because the error I am getting is `Blocked a frame with origin "https://www..com" from accessing a cross-origin frame.` and I don't use iframes on my website, except for the (exceptionally terrible) Drift widget – Vic Seedoubleyew Apr 07 '22 at 15:12
  • But I don't know whether the code triggering this error is mine, trying to access Drift's iframe, or vice versa, or whether it's someone trying to do cross site something – Vic Seedoubleyew Apr 07 '22 at 15:13
  • https://stackoverflow.com/a/25098153/5962802 - probably you're trying to access something inside the IFRAME. – IVO GELOV Apr 08 '22 at 09:16
  • Thanks for the reply. That's the thing, I don't think I am. I am using Drift's SDK, but apart from that I don't think I am meddling with its iframe. – Vic Seedoubleyew Apr 11 '22 at 14:51
  • Thanks for the reply. That's the thing, I don't think I am. I am using Drift's SDK, but apart from that I don't think I am meddling with its iframe. – Vic Seedoubleyew Apr 11 '22 at 14:54

0 Answers0