getsentry / sentry-javascript

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

Firefox-specific stack processing fails in some cases, dropping the event #4129

Closed amakhrov closed 1 year ago

amakhrov commented 2 years ago

Package + Version

Version:

current master branch, the same for last 2 years

0.0.0

Description

https://github.com/getsentry/sentry-javascript/blob/a6f8dc26a4c7ae2146ae64995a2018c8578896a6/packages/browser/src/tracekit.ts#L148-L154

This has special handling for firefox It if condition is i === 0. it means it's the very first iteration of the loop, and no frames have been pushed to the stack array. However, below the code tries to access it (stack[0].column), which throws an exception, gets caught higher in the call stack and results in silently dropping the event

AbhiPrasad commented 2 years ago

Hey, thanks for writing in. I agree the tracekit logic should be improved here, and we welcome PRs to address this!

amakhrov commented 2 years ago

@AbhiPrasad After more digging I realize that the particular issue I'm observing is specific to Angular (which appends zone name to every stacktrace line). This generally breaks the regex (gecko variable in tracekit.ts).

So even if the logical error (accessing undefinedstack[0].column) is fixed, preventing the runtime error, the stacktrace will still not be parsed correctly overall.

Probably the right answer is making the regex more permissive - but it can potentially introduce regressions (if there are cases not covered by existing unit tests)

amakhrov commented 2 years ago

In our project we ended up disable zone-error plugin, so the zone name is no longer added to stack traces, and the problem reported above is no longer reproduced. I don't know any other way to activate the branch of code with the error - or is it even possible in current versions of Firefox (looks like the code was authored quite long ago).

HazAT commented 1 year ago

Closing this, seems to be a weird edge case and probably no longer relevant.