getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.97k stars 1.57k forks source link

Stack trace is incorrectly parsed, concatenates identifier with file path [Firefox] #4138

Closed amakhrov closed 2 years ago

amakhrov commented 2 years ago

Package + Version

Version:

6.8.0

Description

Raw stack trace is:

$i/<@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:281638
$i@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:281652
Qi/<@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:280865
Qi@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:280932
remove@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:337263
_applyChanges/<@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:214312
forEachOperation@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:322334
_applyChanges@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:214085
ngDoCheck@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:214037
Ce@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:262471
Ee@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:262272
xe@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:261947
Er@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:286182
Sr@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:286076
Qr@https://www.crunchbase.com/main.4a4119c3cdfd10266d84.js:146:1015148
jr@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:289910
Mr@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:288548
Mr/<@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:288975
Mr@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:289000
Mr/<@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:288975
Mr@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:289000
Mr/<@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:288975
Mr@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:289000
us@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:296021
detectChanges@https://www.crunchbase.com/vendor.d1cae9cfc9917df88de7.js:1:333807
handleProfileResult@https://www.crunchbase.com/main.4a4119c3cdfd10266d84.js:146:1018410
next@https://www.crunchbase.com...

Note this frame:

handleProfileResult@https://www.crunchbase.com/main.4a4119c3cdfd10266d84.js:146:1018410

In Sentry it's displayed as

function: "handlePro"
abs_path: "fileResult@https://www.crunchbase.com/main.4a4119c3cdfd10266d84.js"

It's the only frame in the whole stack trace that is messed up.

amakhrov commented 2 years ago

On the first glance it looks like some regex matches the file substring there as a special delimiter :)

github-actions[bot] commented 2 years ago

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

amakhrov commented 2 years ago

I mean, it's still a legit issue, and keeps popping up from time to time in our project ("profile" is a part of our domain terminology, so we cannot simply rename all occurrences in the code to make Sentry SDK happy)

rhcarvalho commented 2 years ago

I confirm there are other inputs that produce unexpected results when run through https://github.com/getsentry/sentry-javascript/blob/cabb53c67ab202bb12c517f8a4aa65641cac606e/packages/browser/src/tracekit.ts#L147

Examples:

> const gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
> gecko.exec('handleProfileResult@https://www.crunchbase.com/main.4a4119c3cdfd10266d84.js:146:1018410')
(6) ['handleProfileResult@https://www.crunchbase.com/main.4a4119c3cdfd10266d84.js:146:1018410', 'handlePro', undefined, 'fileResult@https://www.crunchbase.com/main.4a4119c3cdfd10266d84.js', '146', '1018410', index: 0, input: 'handleProfileResult@https://www.crunchbase.com/main.4a4119c3cdfd10266d84.js:146:1018410', groups: undefined]
> gecko.exec('helloHTTPMethod@https://www.crunchbase.com/main.4a4119c3cdfd10266d84.js:146:1018410')
(6) ['helloHTTPMethod@https://www.crunchbase.com/main.4a4119c3cdfd10266d84.js:146:1018410', 'hello', undefined, 'HTTPMethod@https://www.crunchbase.com/main.4a4119c3cdfd10266d84.js', '146', '1018410', index: 0, input: 'helloHTTPMethod@https://www.crunchbase.com/main.4a4119c3cdfd10266d84.js:146:1018410', groups: undefined]

Touching that regexp is going to require the due diligence (and possibly regular expressions are not the best tool for the job).

vladanpaunovic commented 2 years ago

@kamilogorek could you help us here? Is this something that the Stacktrace team can pick up?

kamilogorek commented 2 years ago

@vladanpaunovic the original issue has been already addressed here - https://github.com/getsentry/sentry-javascript/pull/4153 It just needs to be rebased on top of v7 changes and merged in.