Skip to content

Commit e4e9db2

Browse files
committed
test(utils): test fallback to last
1 parent d59a812 commit e4e9db2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/utils/src/stacktrace.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,26 @@ export function stripSentryFramesAndReverse(stack: ReadonlyArray<StackFrame>): S
6565
return [];
6666
}
6767

68-
let localStack = stack.slice(0, STACKTRACE_LIMIT);
68+
const localStack = stack.slice(0, STACKTRACE_LIMIT);
6969

7070
const lastFrameFunction = localStack[localStack.length - 1].function;
71-
// If stack ends with one of our internal API calls, remove it (ends, meaning it's the bottom of the stack - aka top-most call)
71+
// If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
7272
if (lastFrameFunction && /sentryWrapped/.test(lastFrameFunction)) {
7373
localStack.pop();
7474
}
7575

7676
// Reversing in the middle of the procedure allows us to just pop the values off the stack
77-
localStack = localStack.reverse();
77+
localStack.reverse();
7878

7979
const firstFrameFunction = localStack[localStack.length - 1].function;
80-
// If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
80+
// If stack ends with one of our internal API calls, remove it (ends, meaning it's the bottom of the stack - aka top-most call)
8181
if (firstFrameFunction && /captureMessage|captureException/.test(firstFrameFunction)) {
8282
localStack.pop();
8383
}
8484

8585
return localStack.map(frame => ({
8686
...frame,
87-
filename: frame.filename || localStack[0].filename,
87+
filename: frame.filename || localStack[localStack.length - 1].filename,
8888
function: frame.function || '?',
8989
}));
9090
}

0 commit comments

Comments
 (0)