You Really Should Log Client-Side Errors
Published 3 years 7 months ago on April 4, 2012 — 1 min read
This isn’t something I’ve really thought much about implementing but makes a lot of sense. With so much being offloaded to the client side, there’s an increased potential for errors. We’ve got our test driven development and do what we can to write bug-free code, but as things continue to shift, that issue is going to only become more prominent.
By simply binding the
window.onerror event, we can pass along any errors that pop up to the log on our server via AJAX. As per the article, we can hook into
ajaxError as well, but there’s a small can of worms opened when doing that.
Aside from the neat walkthrough, this can really get you thinking about better handling client side errors you may be missing at this point. As per the comments, there are some additional issues to take into consideration like a malicious abuse of the system resulting in full hard drives on the server. Naturally appropriate precautions should be taken to avoid such issues, but we’re already potentially exposed to the same issues with the form-based implementations we’re already using, right?