-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Stack Parsing #4543
Comments
At some point this week I'm guessing #3729 is going to become a blocker to progress. I've run the tests locally both on macOS and Windows and everything passes so I'm at a bit of a loss as to how to fix this! |
When we finally allow users to pass in/configure stack line parsers we run into the issue of order/priority. The order that the line parsers are attempted is key so we need to add some kind of priority. Currently the line parser type is: type StackLineParser = (line: string) => StackFrame | undefined; We could add a property to the function and change the type to something like: interface StackLineParser {
(line: string): StackFrame | undefined;
priority: number;
} You could configure this like: const myParser: StackLineParser = Object.assign(
line => {
// parser here
},
{ priority: 10 }
); But that would add quite a bit to the bundle. A helper function might make parser creation take up less bundle size: function createParser(fn: (line: string): StackFrame | undefined, priority: number): StackLineParser {
return Object.assign(fn, { priority });
}
const myParser = createParser( line => { /* parser here */ }, 10); Alternatively, a plain object interface is an option: interface StackLineParser {
fn: (line: string): StackFrame | undefined;
p: number;
} |
Could we maybe use an array? I used a similar strategy for the envelope types: https://github.com/getsentry/sentry-javascript/pull/4527/files#diff-98566cdbe00d44614c2fa27bf3e2ffabc236cf66528242495ea172d7fcb6ca0aR18-R25 |
That would work. Those array type definitions are 👌 |
Trying to decide how to expose the stack parser config to Browser SDK consumers and the Electron SDK. I can put it in the Do you see any point exposing the parser for other SDKs? |
React Native is the only one that comes to my mind here, but they seem to just use browser's stuff https://github.com/getsentry/sentry-react-native/blob/33232d9ef157e4c4059f618cee348f9bd16af8fd/src/js/backend.ts#L45-L61 |
@timfish this should be good to close right? |
Yes! |
Currently the JavaScript stack parsing is made up of:
node-stack-parse
for node.jsThese are currently working well but there is scope for improvement:
This quick PoC shows that the stack line parsers can be moved into individual functions that will allow features to be configurable.
Rough Plan
Make incremental improvements, starting with non-breaking changes:
node-stack-parse
to the common parserframeContextLines
frameContextLines
option and move to integration sentry-docs#4746Then breaking changes for next major version:
stackParser
toinit
options so it can be overridden in downstream SDKsevent.stacktrace
event.stacktrace
#4885frameContextLines
fromNodeOptions
since this will now be passed to the integrationframeContextLines
#4884eventbuilder
exports which were at some point used in@sentry/electron
@sentry/electron
#4887A stack parser that can handle both Chrome and Node.js frames might be constructed like:
The text was updated successfully, but these errors were encountered: