I am using a window.onerror=function(msg, url, linenumber) to send myself an email when a javascript error occurs. When I use my webpages (IE, FF, CHRM, ect) I do not receive any errors. However I am getting all kinds of errors emailed to me from other users that I cannot duplicate. I am probably getting an error happening on 1% of the users visiting the website so 1/100 page loads I get an error. Here are some:
Syntax error: http://www.google-analytics.com/ga.js
Error loading script: http://www.google-analytics.com/ga.js
Error loading script: https://seal.thawte.com/getthawteseal?host_name=XXX&size=M&lang=en
$("input.datepicker").datepicker is not a function
Uncaught SyntaxError: Unexpected token
Object doesn't support this property or method
Uncaught TypeError: Object [object Object] has no method 'dialog'
Syntax error: http://seal-cencal.bbb.org/logo/XXX
Error: Permission denied to access property 'toString'
What I don't understand is the website 99% of the time is running without any errors and I can't seem to get an error to happen for me on any browser I use. I am also tracking what browsers the users are using who send these errors and it's random, all sorts of browsers and they are all newer FF, IE versions mainly.
How do you stop syntax errors on external code (but they work most of the time)...?
How come google and thawte scripts fail to load some people so often but never happens to me, is there a way to have a fallback to this?
The datepicker one, I can only assume its error out because jquery UI failed to load because jquery loads (otherwise it wouldn't get called inside a document ready call) but I even have a localhost jquery UI script fallback include and it still happens..
Does anyone have a suggestion for me to help me further debug/fix these problems. The thing is, the website gets a lot of hits I am getting about 1 error emailed to me every minute (and it's not the same user causing each error). If you have any suggestions let me know (remember the code and website work fine 99% of the time so I don't think its a syntax problem on my end anywhere).
Thanks for your time.
How do you stop syntax errors on external code (but they work most of the time)...?
You can't really. Without a more detailed message investigation is quite impossible. Notice that sysntax errors might be caused by something else as well, their origin might not be in the external script. I doubt Google Analyticts serves invalid scripts.
How come google and thawte scripts fail to load some people so often but never happens to me
They might use adblockers or similiar against those. Not everyone wants his web usage logged by google. Also, some proxies might ignore/block them, like intranet firewalls.
is there a way to have a fallback to this?
You could try serving them from your own domain as a proxy. Or just ignore them, I don't think your app really needs a fallback for those.
The datepicker one, I can only assume its error out because jquery UI failed to load as jquery still loads
Yes, that sounds likely. Or it just didn't load before it was called.
but I even have a localhost jquery UI script fallback include and it still happens..
Localhost? I guess you mean a copy on your server. Still, it depends on the details how the script and its fallback version are loaded.
Does anyone have a suggestion for me to help me further debug/fix these problems.
A stack trace would help a lot to locate the user's action that caused the error.
Most of the errors on the list are caused by errors in browser extensions.
If you really want to log JavaScript errors, it is best you also log the stack trace if available. I also log details about functions that execute and the arguments sent to it. When the error is caught I cut X amount of stuff from the stack I built and send that up as well.
Related
Is it possible to track the number of errors and warning thrown by a browser on page load using javascript?
For example CSS Assets missing or images missing or js script errors? I don't need a detailed log but maybe a count of each type of error.
Like a count of CSS, Assets missing and JS Errors?
This needs to be tracked using JS and not in the console. The script needs to collect all these errors from the console and send them back to my server.
Yea, absolutely. There are a number of ways to do this.
For JavaScript, you can capture errors by listening to window.onerror. This will give you the error information and you can AJAX the data back to your infrastructure.
If you don't want to support the infrastructure log them yourself, you can use a JavaScript Error Logging service like TrackJS to do this automatically.
For Asset load failures, you can attach onerror listeners to the css tags, although this won't work in all browsers. You could send the load failures back to the same logging infrastructure.
You should also check out the new proposed standard on Network Error Logging, which might be relevant for what you're trying to do.
EDIT: I've added clarifications in response to a comment; where it's possible and meaningful, those added carifications are in italic font style.
I've posted this question on Firefox groups as well as here on SO.
There are at least 25 related questions on SO, a few representative questions being:
Flash bug
cross-domain issue
just a mystery
FF XPCOM problem
There are ~15 accepted answers, none of which seem to apply here. Because there are so many questions and accepted answers, I am assuming that my question addresses an issue that developers have often tripped over.
I have written a straight-up web page that, in my view, is completely normal and usual. I have nothing unusual on the page, nothing that I -- and probably you and all web developers -- haven't been using for the past ten years at least.
I'm viewing the page I've developed with Firefox 3.6.16 with Firebug 1.6.2.
With varying periodicity, but typically every 30 to 60 minutes for 65% of the incidents, an error message shows up in the Firebug console:
Permission denied for <http://ad.yieldmanager.com> to call method Location.toString
Most of these message point at yieldmanager, but I see complaints about doubleclick and interclick as well. FB gives me no properties about the error messages.
View->Source of the page shows nothing about yieldmanager or any other offender.
There are calls to AdSense, but removing that code entirely changes nothing wrt the error messages.
There are about 3000 line of plain, vanilla-type JavaScript on the page but nothing at all exotic that I can see.
I have not explicitly or (I believe) implicitly included any framework code: no JScript, xjs, MooTools, not anything.
Question: How can I find out who is calling Location.toString( ); and how can I get rid of that guy?
This may not be the case with you at all, however be aware that firebug will display error messages in your console if you open-up another window and browse to a site that has these calls. In short, these errors may not be related to your page at all.
Per my comment, try disabling extensions (safe mode) and check Firebug's XHR tab if you haven't already.
I don't know if this has been asked before, but what i'd like to be able to do is get data from the error console within the browser itself(if it supports it) this would be for when a user sends off a bug report it'd pull up any errors related to pages at my website for things such as typos in code and other things that somehow managed to slip by. Also, in that regard is there a way to pass the errors from the console to a useable format? If this isn't possible, then i could just tell them to copy and paste what came up from the site itself.
I thought of this right now as i was thinking about how to make the bug reporting system run better since the entire thing is basically ran within the browser and for the backend I can easily just look at error logs but for the frontend ie javascript bits of things it's not goign to be as easy.
So to finish wrap all of this up in one little statement, is there an easy way to get the data from the error console and be able to send it along via javascript ie to a form, or something similar.
You can use the onerror event in JS to get the details of the error. Hoptoad do this for example and log the errors to their console, Their code re-uses lots of nice JS scripts including a printStackTrace function that is great.....
You can see how they do it here:
http://hoptoadapp.com/javascripts/notifier.js
I'm having problems with getting decent JavaScript error invormation in a Production environment.
When I'm developing I can just attach a debugger and (usually) fix the problem.
When I get the same error in a production environment however at best I see is an error report that looks like this:
Error: Object doesn't support this property or method
Url: SomePage
Line: 42
Char: 13
Which doesn't help me very much - I can't see the rendered page and so I have no idea what line 42 looks like.
Is there any way for me to log the entire rendered page contents whenever an error like this occurs? (So line 42 of the output is the line where the error occured)
While I'm at it, are there any other techniques that I can use to help with getting useful error information from JavaScript (without need to break into the debugger) - failing that is there any way that I can structure my JavaScript slightly differently to help getting decent debug information?
I'm predominantly interested in IE - this is the browser that tends to cause me most problems.
I don't think you'll be able to get the exact original HTML source of the page back in all pages and all browsers.
Regarding debugging, you could use a logging library such as log4javascript (disclaimer: I wrote it) and intersperse logging calls in your code. log4javascript enables you to send logging messages back to the server via Ajax.
Unfortunately, IE has by default the most utterly useless error reporting. The script and line number reported in the error are essentially guaranteed to be absolutely wrong. You can, however, install the IE developer tool bar (for IE7 and older, it's built into IE8) from Microsoft, which can help track down the error source.
I get the following error in firebug in Firefox 3 with both MooTools and jQuery:
"p.onStatusChange is not a function".
I've noticed this error frequently in firebug since one of the latest updates of FF3. However, it has started appearing with code that hasn't been changed in some time and that was not reporting errors previously. The errors happens when ajax results are returned. It shows up in different applications that use separate javascript libraries, MooTools and jQuery.
Does anyone have any idea why these errors are appearing? My intuition tells me that it is something in Firefox that changed, but I can't find any information online currently. The ajax calls still work fine, but I am wary of just going with my intuition and leaving script errors in my code.
Thanks,
Jason
I get it in tabBrowser instead:
chrome://browser/content/tabbrowser.xml
(4) errors occur:
p.onStatusChange
p.onProgressChange
p.onStateChange
p.onSecurityChange
What I found was that the add-on "PDF Download" was causing these errors. The best way for me to check was to go to a page that produced the errors, turn off all the add-ons, and turn them on one-by-one (starting with Firebug). Instead of going one-by-one, I actually turned them on in lots of 3 to help identify the problem sooner.
Here is the reference for the function NsIDownloadProgressListener. It looks like it has been deprecated.