Currently the JavaScript stack parsing is made up of:
- Highly modified version of Tracekit for the browser
- Mildly modified version of
node-stack-parse for node.js
These are currently working well but there is scope for improvement:
- Multiple refactors have resulted in unused fields/code paths and unnecessary abstractions
- Downstream SDKs cannot configure the parser
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:
Then breaking changes for next major version:
A stack parser that can handle both Chrome and Node.js frames might be constructed like:
import { createStackParser } from '@sentry/utils';
import { chrome } from '@sentry/browser';
import { node} from '@sentry/node';
import { Exception } from '@sentry.types';
const stackParser = createStackParser(chrome, node);
try {
throw new Error('bad things');
} catch(e) {
const ex: Exception = stackParser(e);
}
Currently the JavaScript stack parsing is made up of:
node-stack-parsefor 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-parseto the common parserframeContextLinesframeContextLinesoption and move to integration sentry-docs#4746Then breaking changes for next major version:
stackParsertoinitoptions so it can be overridden in downstream SDKsevent.stacktraceevent.stacktrace#4885frameContextLinesfromNodeOptionssince this will now be passed to the integrationframeContextLines#4884eventbuilderexports 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: