JavaScript Debugging Gotchas! IE9

July 14, 2015 By 0 Comments

Yesterday, we had a bug report from one of our clients in regards to a web-based system we develop for them. In short, this part of the system handles creating and modifying data, and then saving it for later use.  The report came in that the Save methods weren’t working anymore. These are handled by JavaScript, and we know that this particular client is locked down to Internet Explorer 9. There was a bit of a sigh after the call, and investigation began.

The issue was not repeatable on the browsers on my system, so that was clue #1. The client demonstrated it happening on their browser. Broken. Open the F12 Developer Tools, magically it’s fixed again. So the issue is something that happens that only when Developer Tools are not present. Last time I came across this, it was for  console.log().

The console object only exists in IE9 when the Developer Tools are open. After this came up last time, it was resolved by adding guards to protect against it’s absence.

Turns out in this case, even though these guards had solved the issue before, some IE9 settings or minor versions or something affect this; when it happens, it’s always going to happen on the machine. When it doesn’t, it never seemed to.

I’m not yet sure what the difference is, but two side-by-side machines running the same locked down system image (IE9 included) reliably demonstrated different behaviours. Removing the console.log code entirely certainly seemed to fix the issue, but this seems awfully hacky to me, as well as a case of “Fixing the symptom, not the cause”. While the client is happy for now, I would like to know if anyone happens to know what might cause the difference here.

Please leave a comment if you have any ideas, although I will keep investigating to see if I can come up with anything either.