Skip to content
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
50 changes: 50 additions & 0 deletions packages/browser/test/unit/tracekit/chromium.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,4 +497,54 @@ describe('Tracekit - Chrome Tests', () => {
},
});
});

it('should parse webpack wrapped exceptions', () => {
const EXCEPTION = {
message: 'aha',
name: 'ChunkLoadError',
stack: `ChunkLoadError: Loading chunk app_bootstrap_initializeLocale_tsx failed.
(error: https://s1.sentry-cdn.com/_static/dist/sentry/chunks/app_bootstrap_initializeLocale_tsx.abcdefg.js)
at (error: (/_static/dist/sentry/chunks/app_bootstrap_initializeLocale_tsx.abcdefg.js))
at key(webpack/runtime/jsonp chunk loading:27:18)
at ? (webpack/runtime/ensure chunk:6:25)
at Array.reduce(<anonymous>)`,
};

const ex = exceptionFromError(parser, EXCEPTION);

expect(ex).toEqual({
value: 'aha',
type: 'ChunkLoadError',
stacktrace: {
frames: [
{ filename: '<anonymous>', function: 'Array.reduce', in_app: true },
{
filename: 'webpack/runtime/ensure chunk',
function: '?',
in_app: true,
lineno: 6,
colno: 25,
},
{
filename: 'webpack/runtime/jsonp chunk loading',
function: 'key',
in_app: true,
lineno: 27,
colno: 18,
},
{
filename: '/_static/dist/sentry/chunks/app_bootstrap_initializeLocale_tsx.abcdefg.js',
function: '?',
in_app: true,
},
{
filename:
'https://s1.sentry-cdn.com/_static/dist/sentry/chunks/app_bootstrap_initializeLocale_tsx.abcdefg.js',
function: '?',
in_app: true,
},
],
},
});
});
});
6 changes: 5 additions & 1 deletion packages/utils/src/stacktrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ export function createStackParser(...parsers: StackLineParser[]): StackParser {
const frames: StackFrame[] = [];

for (const line of stack.split('\n').slice(skipFirst)) {
// https://github.com/getsentry/sentry-javascript/issues/5459
// Remove webpack (error: *) wrappers
const cleanedLine = line.replace(/\(error: (.*)\)/, '$1');

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

if (frame) {
frames.push(frame);
Expand Down