<story><title>You Really Should Log Client-Side Errors</title><url>http://openmymind.net/2012/4/4/You-Really-Should-Log-Client-Side-Error/</url></story><parent_chain></parent_chain><comment><author>rakeshpai</author><text>I&apos;m the developer of Errorception (&lt;a href=&quot;http://errorception.com/&quot; rel=&quot;nofollow&quot;&gt;http://errorception.com/&lt;/a&gt;), and wanted to jump in to talk about some of the points raised on the thread here.&lt;p&gt;As chrisacky mentioned, making one HTTP post for every error is very wasteful. It&apos;s much better to buffer up such errors (Errorception does it in memory, since localStorage can be unavailable and/or full), and post them every once in a while.&lt;p&gt;As masklinn pointed out, window.onerror _is_ complete shit, so Errorception does a couple of tricks to make this slightly better. Firstly, on IE, the stack isn&apos;t lost when window.onerror is called, so it&apos;s possible to get the call stack and arguments at each level of the stack. Secondly, it&apos;s very easy to get other kind of details (browser, version, page, etc.), which helps a great deal in aiding debugging.&lt;p&gt;However, masklinn&apos;s suggestion about wrapping code in try/catch blocks is probably not a good idea. This is because some interpreters (I know v8 does this) don&apos;t compile the code in such code-paths. May cause a performance hit.&lt;p&gt;As DavidPP mentioned, depending on the nature of your application, it might be a good idea to not record too much sensitive information. For example, Errorception doesn&apos;t record function arguments if the page is served over SSL.&lt;p&gt;troels is right - this does create a massive flood of errors. There are several ways to deal with this. What we do for example, is hide away errors from most third-parties - Facebook, Twitter, GoogleBot, GoogleAnalytics, etc. The rest of the errors can still be huge in number, so we group similar errors together based on several parameters like browsers, browser versions, possible variation in inline code line-numbers because of dynamic content, etc.&lt;p&gt;Also, as Kartificial pointed out, this is probably something you don&apos;t want to do on your own server. You want to move this out of your infrastructure, and distribute it if possible.&lt;p&gt;There are other concerns - some that come to mind are page load time, ensuring that your error catching code itself doesn&apos;t raise errors (or if it does, it doesn&apos;t affect your app in any way), and that of managing data-growth on the server. These are fun problems, but it&apos;s probably not worth re-inventing the wheel.&lt;p&gt;&amp;#60;/plug&amp;#62;</text></comment>
<story><title>You Really Should Log Client-Side Errors</title><url>http://openmymind.net/2012/4/4/You-Really-Should-Log-Client-Side-Error/</url></story><parent_chain></parent_chain><comment><author>chrisacky</author><text>Theory correct. Implementation wrong.&lt;p&gt;If I was actually doing this and wanted to run it on a production site, I would certainly not fire off a post on each error. The most likely solution that I would use off the top of my head would be to store the data in localStorage of the current user where supported.&lt;p&gt;You wouldn&apos;t need to collect &lt;i&gt;every&lt;/i&gt; &lt;i&gt;single&lt;/i&gt; &lt;i&gt;error&lt;/i&gt;, but just a sample. You shouldn&apos;t really need to be that concerned with the totally extreme edge cases, and if you are triaging correctly then it&apos;s the most common errors that you want to look out for.&lt;p&gt;So I would implement something that would result in a random selection of my visitors from collecting the errors for me and also have a buffer and client side rate limit included into the application so that errors are saved up, and sent in bulk.&lt;p&gt;As I start collecting errors which I realise are totally beyond my control, I would then start dropping errors generated from particular files and extensions installed and stop logging them.&lt;p&gt;Logging &lt;i&gt;everything&lt;/i&gt; is wrong in my opinion.&lt;p&gt;Edit:&lt;p&gt;Yes I would do the &lt;i&gt;bulk&lt;/i&gt; of deciding what to log on the server. However, I think I would still have some standard rules that I know I can apply to disregard certain error events. But since I would constantly be working over the logs, the majority would be done server side.</text></comment>