@@ -50,14 +50,29 @@ function createFrame(filename: string, func: string, lineno?: number, colno?: nu
5050 return frame ;
5151}
5252
53- // Chromium based browsers: Chrome, Brave, new Opera, new Edge
53+ // This regex matches frames that have no function name (ie. are at the top level of a module).
54+ // For example "at http://localhost:5000//script.js:1:126"
55+ // Frames _with_ function names usually look as follows: "at commitLayoutEffects (react-dom.development.js:23426:1)"
56+ const chromeRegexNoFnName = / ^ \s * a t ( \S + ?) (?: : ( \d + ) ) (?: : ( \d + ) ) \s * $ / i;
57+
58+ // This regex matches all the frames that have a function name.
5459const chromeRegex =
5560 / ^ \s * a t (?: ( .+ ?\) (?: \[ .+ \] ) ? | .* ?) ? \( (?: a d d r e s s a t ) ? ) ? (?: a s y n c ) ? ( (?: < a n o n y m o u s > | [ - a - z ] + : | .* b u n d l e | \/ ) ? .* ?) (?: : ( \d + ) ) ? (?: : ( \d + ) ) ? \) ? \s * $ / i;
61+
5662const chromeEvalRegex = / \( ( \S * ) (?: : ( \d + ) ) (?: : ( \d + ) ) \) / ;
5763
64+ // Chromium based browsers: Chrome, Brave, new Opera, new Edge
5865// We cannot call this variable `chrome` because it can conflict with global `chrome` variable in certain environments
5966// See: https://github.com/getsentry/sentry-javascript/issues/6880
6067const chromeStackParserFn : StackLineParserFn = line => {
68+ // If the stack line has no function name, we need to parse it differently
69+ const noFnParts = chromeRegexNoFnName . exec ( line ) ;
70+
71+ if ( noFnParts ) {
72+ const [ , filename , line , col ] = noFnParts ;
73+ return createFrame ( filename , UNKNOWN_FUNCTION , + line , + col ) ;
74+ }
75+
6176 const parts = chromeRegex . exec ( line ) ;
6277
6378 if ( parts ) {
0 commit comments