Resolving difficult to recreate bugs
In a js app I'm developing there are a few bugs that recur every now and then for some users who are testi开发者_如何学运维ng it, but I've been unable to recreate them myself.
What tools/approaches are there to debug bugs which are difficult to recreate, or which only seem to happen on a computer the developer doesn't have access to?
The very first thing I do is get the user agent of the person who saw the bug, so I can check it and make sure I'm testing on the exact same browser version and operating system. They can see their user agent by going to http://whatsmyuseragent.com/
I also ask for a screencast if possible--sometimes I think I'm doing the exact same steps they are, but actually I misunderstood what they meant.
For really tough bugs, I try to add some logging into the code (maybe add a logging window) so I can figure out which codepaths they hit.
I would recommend creating some unit tests: https://github.com/pivotal/jsunit
I won't belabor the pros and cons of creating a robust unit testing suite here, but even the most basic unit tests should help improve the overall quality of your system and allow you to locate/prevent bugs faster and better.
精彩评论