Skip to content

Commit 3ef3918

Browse files
author
Luca Forstner
authored
fix(utils): Don't attach context lines to stack frames without line number (#6549)
1 parent 6462f67 commit 3ef3918

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/utils/src/misc.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,13 @@ export function parseSemver(input: string): SemVer {
147147
* @param linesOfContext number of context lines we want to add pre/post
148148
*/
149149
export function addContextToFrame(lines: string[], frame: StackFrame, linesOfContext: number = 5): void {
150-
const lineno = frame.lineno || 0;
150+
// When there is no line number in the frame, attaching context is nonsensical and will even break grouping
151+
if (frame.lineno === undefined) {
152+
return;
153+
}
154+
151155
const maxLines = lines.length;
152-
const sourceLine = Math.max(Math.min(maxLines, lineno - 1), 0);
156+
const sourceLine = Math.max(Math.min(maxLines, frame.lineno - 1), 0);
153157

154158
frame.pre_context = lines
155159
.slice(Math.max(0, sourceLine - linesOfContext), sourceLine)

0 commit comments

Comments
 (0)