Skip to content

don't remove anonymous functions from stack trace #290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions test/raven.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@ function now() {
}

describe('TraceKit', function(){
describe('stacktrace info', function() {
it('should not remove anonymous functions from the stack', function() {
// mock up an error object with a stack trace that includes both
// named functions and anonymous functions
var stack_str = "" +
" Error: \n" +
" at namedFunc0 (http://example.com/js/script.js:10)\n" + // stack[0]
" at http://example.com/js/test.js:65\n" + // stack[1]
" at namedFunc2 (http://example.com/js/script.js:20)\n" + // stack[2]
" at http://example.com/js/test.js:67\n" + // stack[3]
" at namedFunc4 (http://example.com/js/script.js:100001)"; // stack[4]
var mock_err = { stack: stack_str };
var trace = TraceKit.computeStackTrace.computeStackTraceFromStackProp(mock_err);

// Make sure TraceKit didn't remove the anonymous functions
// from the stack like it used to :)
assert.equal(trace.stack[0].func, 'namedFunc0');
assert.equal(trace.stack[1].func, '?');
assert.equal(trace.stack[2].func, 'namedFunc2');
assert.equal(trace.stack[3].func, '?');
assert.equal(trace.stack[4].func, 'namedFunc4');
});
});
describe('error notifications', function(){
var testMessage = "__mocha_ignore__";
var subscriptionHandler;
Expand Down
3 changes: 2 additions & 1 deletion vendor/TraceKit/tracekit.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
return null;
}

var chrome = /^\s*at (.+?) ?\(?((?:file|https?|chrome-extension):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
var chrome = /^\s*at (\S*) ?\(?((?:file|https?|chrome-extension):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
gecko = /^\s*(.*?)(?:\((.*?)\))?@((?:file|https?|chrome).*?):(\d+)(?::(\d+))?\s*$/i,
lines = ex.stack.split('\n'),
stack = [],
Expand Down Expand Up @@ -1064,6 +1064,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
}

computeStackTrace.augmentStackTraceWithInitialElement = augmentStackTraceWithInitialElement;
computeStackTrace.computeStackTraceFromStackProp = computeStackTraceFromStackProp;
computeStackTrace.guessFunctionName = guessFunctionName;
computeStackTrace.gatherContext = gatherContext;
computeStackTrace.ofCaller = computeStackTraceOfCaller;
Expand Down