Skip to content

Commit 3376a15

Browse files
authored
ref(utils): test for webpack error before running replace (#7412)
1 parent 161b8f0 commit 3376a15

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/utils/src/stacktrace.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { StackFrame, StackLineParser, StackLineParserFn, StackParser } from '@sentry/types';
22

33
const STACKTRACE_LIMIT = 50;
4+
// Used to sanitize webpack (error: *) wrapped stack errors
5+
const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
46

57
/**
68
* Creates a stack parser with the supplied line parsers
@@ -25,7 +27,7 @@ export function createStackParser(...parsers: StackLineParser[]): StackParser {
2527

2628
// https://github.com/getsentry/sentry-javascript/issues/5459
2729
// Remove webpack (error: *) wrappers
28-
const cleanedLine = line.replace(/\(error: (.*)\)/, '$1');
30+
const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, '$1') : line;
2931

3032
for (const parser of sortedParsers) {
3133
const frame = parser(cleanedLine);

0 commit comments

Comments
 (0)