Script Error on AngularJS SPA

Ritchie

Posted on
Jun 13 2014

I've just set up raygun on production, the site is a single page application using AngularJS. I set up a provider as per this post (https://raygun.io/blog/2014/06/track-angular-js-exceptions-automatically/) to automatically receive any exceptions. I am now receiving 'script error' as a message. The stack trace returns the following:

Script error at p line null, column null (null:null) at [anonymous] line null, column null (null:null)

I'm quite new at this so any help I would really appreciate.

Ritchie


Callum

Posted on
Jun 13 2014

Sorry to hear you're having trouble with this - I assume this message is appearing in the dev console and not in a successfully transmitted Error that has appeared in your Raygun dashboard? Could you please grab and reference the unminified provider from https://raw.githubusercontent.com/MindscapeHQ/raygun4js/master/dist/raygun.js and see if that clarifies the error- also if you could post the code you added to your markup and script that would be helpful.


Ritchie

Posted on
Jun 13 2014

Thanks for replying Callum.

Here is the code that initialises Raygun.

  <script>
        Raygun.init('{{api_key}}').attach();
  </script>

I'm using raygun in a number of ways. In my Angular directives I use the following to debug parts of the code.

I'm using try/catch block for the core functions, such as:

try { loadBlockAssets(); } catch(e) { Raygun.send(e); }

I also have added it on any errors from image load such as:

_tmpImg.onerror = function(){ Raygun.send(new Error('Edit Page: Profile image data uri Error!')); }

And have added a decorator in my AngularJs config to notify me of any exceptions.

I'm about to replace the minified raygun script with the dev version.

Thanks again for your help!


Ritchie

Posted on
Jun 13 2014

So, the prod version seems to be running better. Picking up the exception errors, however it is now also return digest errors, which i dont understand because this should have been picked up in dev.


Ritchie

Posted on
Jun 14 2014

I am still getting a generic script error:

Script Error: at ? line 0, column undefined (:0)

I can't for the life of me figure out why this error has been coming up for the last couple of days.


wtsn

Posted on
Jul 19 2014

Any resolution to this? Running into a similar issue with

Script Error: at ? line 0, column undefined (:0)

using Angular.


Callum

Posted on
Jul 21 2014

Browsers can throw this exception when an error occurs in a script that is hosted on a different domain to the domain of the current page - would this be possible in your current state, e.g. loading external scripts from a CDN? This is done by design in the modern browsers to prevent violation of the same-origin policy and leakage of information to malicious external hosts. An exception is IE9 which does not throw this error.

It would be interesting to see if you can repeatedly trigger this error in Raygun by hitting a particular route, and if you notice it in the console too (naturally, you would have to add a console.log(error) statement to your decorator/factory function after the call to Raygun.send). If you can repro the error, testing it in IE9 would indicate if it is an external script error in this case.


Ritchie

Posted on
Jul 21 2014

This would probably be a good explanation of what was happening in my angular application. I never tried running local files however.


wtsn

Posted on
Jul 21 2014

Yes this is indeed what is happening. Thank you.


Tx3

Posted on
Dec 16 2014

Hi!

I have almost similar situation and I can't figure out exact reason for this and what are the consequences for the user.

Here is the raw data I get from the error. Especially the user agent is really weird. Maybe some device is faking to be iOS device or something.

{
     "Error": {
          "Message": "Script error.",
          "StackTrace": [
               {
                    "LineNumber": 0,
                    "ClassName": "line 0, column undefined",
                    "FileName": "",
                    "MethodName": "?"
               }
          ]
     },
     "Environment": {
          "UtcOffset": 2,
          "Browser-Width": 1280,
          "Browser-Height": 696,
          "Screen-Width": 1280,
          "Screen-Height": 800,
          "Color-Depth": 32,
          "Browser": "Mozilla",
          "Browser-Name": "Netscape",
          "Browser-Version": "5.0 (Linux; U; Android 4.0.4; fi-fi; GT-P7500 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30",
          "Platform": "Linux armv7l"
     },
     "Client": {
          "Name": "raygun-js",
          "Version": "1.13.1"
     },
     "Tags": [],
     "Request": {
          "Url": "http://priimavalmennus.fi/palvelut",
          "QueryString": {},
          "Headers": {
               "User-Agent": "Mozilla/5.0 (Linux; U; Android 4.0.4; fi-fi; GT-P7500 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30",
               "Referer": "http://priimavalmennus.fi/",
               "Host": "priimavalmennus.fi"
          }
     },
     "Version": "Not supplied",
     "User": {
          "Identifier": "404cc7d1-a8fd-c64b-eea8-757af7dedacb",
          "IsAnonymous": true,
          "UUID": "404cc7d1-a8fd-c64b-eea8-757af7dedacb"
     }
} 

Any thoughts on this?


Callum

Posted on
Dec 17 2014

Tx3,

That certainly looks odd. Could you please provide a snippet of how you've included and attached Raygun4JS to your AngularJS setup (for instance, factory/decorator)?

Regards,
Callum Gavin
Mindscape Limited


Tx3

Posted on
Dec 19 2014

The repository is public and can be found from here: https://github.com/ttamminen/priima-valmennus

I forgot to mention that it's not AngularJS app. It's a static web-site generated using Gulp plugins.

In the file _scripts.tpl.html I have following script element.

<script src="/js/vendor/raygun.vanilla.min.js"></script>
<script>
  Raygun.init('bLiA1OFIgC1U6GMr/acPRQ==').attach();
</script>

Could the order of the script elements make difference? Now it's before ending of the , but it's the last script to load.


Callum

Posted on
Dec 19 2014

The order of the scripts would make a difference insofar as that if any errors were to be thrown by scripts loading prior to Raygun4JS being included, those errors would not be transmitted.

As mentioned above, if the script error is occurring in a third party script (namely something that jQuery is throwing, perhaps) browsers won't provide the stack data due to security concerns. To set the provider to ignore these errors, you can configure it with:

Raygun.init('your_api_key', { ignore3rdPartyErrors : true }).attach();

If the error still occurs with this setting enabled let us know.


Reply