Skip to content

Parse Node stacktraces correctly for filenames with spaces #47

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

Merged
merged 3 commits into from
Aug 7, 2019

Conversation

bengourley
Copy link
Contributor

@bengourley bengourley commented Jul 31, 2019

Description

If a filename has spaces in it, it throws off the tokenization of the stackframe, resulting in an incorrect StackFrame object. The filename is reported as everything after the space, e.g.

Parsing this error…

Error
    at Object.<anonymous> (/Users/bengourley/Development/error-stack-parser/scratch/my project/index.js:2:9)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)

Results in this at stackframe[0]:

{
  columnNumber: 9,
  lineNumber: 2,
  fileName: 'project/index.js',
  functionName: 'Object.<anonymous> (/Users/bengourley/Development/error-stack-parser/scratch/my',
  source: '    at Object.<anonymous> (/Users/bengourley/Development/error-stack-parser/scratch/my project/index.js:2:9)'
}

The fix is a little clunky I'll admit – the neatest thing would be to find a regex to supply instead of the split(/\s+/) call, which would only split on spaces that did not occur with parentheses, but I couldn't come up with one.

Motivation and Context

Reported on this repo #46 and now Bugsnag's users are seeing it bugsnag/bugsnag-js#586.

How Has This Been Tested?

Added a test case which fails before the fix is applied.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • node_modules/.bin/jscs -c .jscsrc error-stack-parser.js passes without errors
  • npm test passes without errors
  • I have read the contribution guidelines
  • I have updated the documentation accordingly
  • I have added tests to cover my changes

@@ -6,24 +6,15 @@ module.exports = function(config) {

// Check out https://saucelabs.com/platforms for all browser/platform combos
var customLaunchers = {
slIOS9: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sauce Labs removed iOS9 from this part of their product.

// version: '10.2'
// },
slAndroid4: {
slIOS10: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…but iOS10 now works ✨

// platform: 'macOS 10.12',
// version: '10.2'
// },
slAndroid4: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android 4 was removed too.

@@ -46,7 +46,7 @@
"karma-opera-launcher": "^1.0.0",
"karma-phantomjs2-launcher": "^0.5.0",
"karma-safari-launcher": "^1.0.0",
"karma-sauce-launcher": "^1.1.0",
"karma-sauce-launcher": "^2.0.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrading this dependency fixed this problem which I was also able to see locally: https://travis-ci.org/stacktracejs/error-stack-parser/builds/566016807#L620

Copy link

@sazap10 sazap10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works as expected after the change.

@bengourley bengourley merged commit 0684a29 into master Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants