Skip to content

Commit

Permalink
fix(Telemetry): Ensure telemetry only matches js stacktrace paths
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed May 10, 2021
1 parent 8d56d0e commit a176c8a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils/telemetry/resolve-error-location.js
Expand Up @@ -8,7 +8,7 @@ const resolveErrorLocation = (exceptionTokens) => {
const splittedStack = exceptionTokens.stack.split(/[\r\n]+/);
if (splittedStack.length === 1 && exceptionTokens.code) return '<not available>';

const stacktraceLineRegex = /(?:\s*at.*\((.*)\).?|\s*at\s(.*))/;
const stacktraceLineRegex = /(?:\s*at.*\((.*:\d+:\d+)\).?|\s*at\s(.*:\d+:\d+))/;
const stacktracePaths = [];
for (const line of splittedStack) {
const match = line.match(stacktraceLineRegex) || [];
Expand Down
8 changes: 8 additions & 0 deletions test/unit/lib/utils/telemetry/resolve-error-location.test.js
Expand Up @@ -28,6 +28,14 @@ describe('test/unit/lib/utils/resolve-error-location.test.js', () => {
expect(result).to.equal('<not reflected in stack>');
});

it('should not capture non-stacktrace paths', () => {
const err = new Error('test');
err.stack =
'Could not find a version that satisfies the requirement flask (from versions: none) No matching distribution found for flask.';
const result = resolveErrorLocation(tokenizeException(err));
expect(result).to.equal('<not reflected in stack>');
});

if (process.platform !== 'win32') {
it('should correctly handle paths not enclosed in parentheses', () => {
const err = new Error('test');
Expand Down

0 comments on commit a176c8a

Please sign in to comment.