Skip to content

Commit

Permalink
Merge 5fca5ac into 9e558ee
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed May 10, 2021
2 parents 9e558ee + 5fca5ac commit 3bf20b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
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.*\((.*\.js:\d+:\d+)\).?|\s*at\s(.*\.js:\d+:\d+))/;
const stacktracePaths = [];
for (const line of splittedStack) {
const match = line.match(stacktraceLineRegex) || [];
Expand Down
22 changes: 10 additions & 12 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 All @@ -40,12 +48,7 @@ describe('test/unit/lib/utils/resolve-error-location.test.js', () => {

const result = resolveErrorLocation(tokenizeException(err));
expect(result).to.equal(
[
'node:internal/child_process:403:11',
'node:child_process:573:9',
'/bestzip/lib/bestzip.js:75:29',
'/async/dist/async.js:1802:20',
].join('\n')
['/bestzip/lib/bestzip.js:75:29', '/async/dist/async.js:1802:20'].join('\n')
);
});

Expand Down Expand Up @@ -84,12 +87,7 @@ describe('test/unit/lib/utils/resolve-error-location.test.js', () => {

const result = resolveErrorLocation(tokenizeException(err));
expect(result).to.equal(
[
'node:internal/child_process:403:11',
'node:child_process:573:9',
'/bestzip/lib/bestzip.js:75:29',
'/async/dist/async.js:1802:20',
].join('\n')
['/bestzip/lib/bestzip.js:75:29', '/async/dist/async.js:1802:20'].join('\n')
);
});

Expand Down

0 comments on commit 3bf20b2

Please sign in to comment.