I believe I have found the cause of these error reports missing line numbers.
I could be wrong - but I thought I would share as I currently I debugging in production and source and line numbers are off a bit…
Not quite the root cause - but I can cause it in Google Chrome 39 dependably.
I believe that when an AJAX call fails for whatever reason we are seeing these JavaScript errors with no source, line number or column number.
###Steps to reproduce
- Set Discourse instance to “Read-Only” mode
- Open Chrome to topic page
- Open debug console Ctrl + Shift + i
- Copy this line onto clipboard
window.onerror = function(m, u, l, c, errorObj) { console.log(m, u, l, c, errorObj, errorObj.stack); }
- Refresh page
- Wait for page to load
- As soon as it seems complete Paste and Execute the line copied to the clipboard.
Note that all we have really done here is replace this function:
https://github.com/discourse/logster/blob/bbd1a7ae11ad10c7961092eb085439dbeab79e0b/vendor/assets/javascripts/logster.js.erb#L10
With one that will allow Chrome to help us find the source of the error.
And if you were using un-minified sources you could just as easy use window.onerror = null
to get better debugging in Chrome.
###Expected Output
Lines to be output including line numbers
###Actual Output
undefined null null null Object {readyState: 4, getResponseHeader: function, getAllResponseHeaders: undefined
Note the source, line and column numbers are null.
###Explanation
Note that the object output is from the Timing call here:
https://github.com/discourse/discourse/blob/f66c39c63bfa57318f742b672b02a02ab18b68a3/app/assets/javascripts/discourse/lib/screen_track.js#L123
Using the Ajax call here:
https://github.com/discourse/discourse/blob/271374a8c62b247d826f8bdfc648da8f36dc8618/app/assets/javascripts/discourse/mixins/ajax.js#L43
So to repeat:
I believe that when an AJAX call fails for whatever reason we are seeing these JavaScript errors with no source, line number or column number.
I’m not just thinking the timing AJAX calls have this issue - perhaps others do too?
Until this is proven true or false I believe suppression is perhaps the wrong thing to do and perhaps indicative of an actual problem existing.
Feel free to call me crazy, slap me about and tell me I’m wrong.