Skip to content

Commit 807bfd1

Browse files
committed
Merge pull request #536 from getsentry/firefox-ns-error
Handle stacks from internal exceptions sometimes thrown by Firefox
2 parents f6ab386 + 27656e7 commit 807bfd1

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

test/vendor/fixtures/captured-errors.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,24 @@ CapturedExceptions.FIREFOX_31 = {
223223
columnNumber: 12
224224
};
225225

226+
// Internal errors sometimes thrown by Firefox
227+
// More here: https://developer.mozilla.org/en-US/docs/Mozilla/Errors
228+
//
229+
// Note that such errors are instanceof "Exception", not "Error"
230+
CapturedExceptions.FIREFOX_44_NS_EXCEPTION = {
231+
message: "",
232+
name: "NS_ERROR_FAILURE",
233+
stack: "[2]</Bar.prototype._baz/</<@http://path/to/file.js:703:28\n" +
234+
"App.prototype.foo@file:///path/to/file.js:15:2\n" +
235+
"bar@file:///path/to/file.js:20:3\n" +
236+
"@file:///path/to/index.html:23:1\n" + // inside <script> tag
237+
"",
238+
fileName: "http://path/to/file.js",
239+
columnNumber: 0,
240+
lineNumber: 703,
241+
result: 2147500037
242+
};
243+
226244
CapturedExceptions.SAFARI_6 = {
227245
message: "'null' is not an object (evaluating 'x.undef')",
228246
stack: "@http://path/to/file.js:48\n" +

test/vendor/tracekit-parser.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ describe('TraceKit', function () {
108108
expect(stackFrames.stack[2]).toEqual({ url: 'http://path/to/file.js', func: '.plugin/e.fn[c]/<', args: [], line: 1, column: 1, context: null });
109109
});
110110

111+
it('should parse Firefox 44 ns exceptions', function () {
112+
var stackFrames = TraceKit.computeStackTrace(CapturedExceptions.FIREFOX_44_NS_EXCEPTION);
113+
expect(stackFrames).toBeTruthy();
114+
expect(stackFrames.stack.length).toBe(4);
115+
expect(stackFrames.stack[0]).toEqual({ url: 'http://path/to/file.js', func: '[2]</Bar.prototype._baz/</<', args: [], line: 703, column: 28, context: null });
116+
expect(stackFrames.stack[1]).toEqual({ url: 'file:///path/to/file.js', func: 'App.prototype.foo', args: [], line: 15, column: 2, context: null });
117+
expect(stackFrames.stack[2]).toEqual({ url: 'file:///path/to/file.js', func: 'bar', args: [], line: 20, column: 3, context: null });
118+
expect(stackFrames.stack[3]).toEqual({ url: 'file:///path/to/index.html', func: '?', args: [], line: 23, column: 1, context: null });
119+
});
120+
111121
it('should parse Chrome error with no location', function () {
112122
var stackFrames = TraceKit.computeStackTrace({stack: "error\n at Array.forEach (native)"});
113123
expect(stackFrames.stack.length).toBe(1);

vendor/TraceKit/tracekit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
616616
if (isUndefined(ex.stack) || !ex.stack) return;
617617

618618
var chrome = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|<anonymous>).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,
619-
gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|\[).*?)(?::(\d+))?(?::(\d+))?\s*$/i,
619+
gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|\[native).*?)(?::(\d+))?(?::(\d+))?\s*$/i,
620620
winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:ms-appx|https?|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
621621
lines = ex.stack.split('\n'),
622622
stack = [],

0 commit comments

Comments
 (0)