Skip to content
This repository was archived by the owner on Sep 28, 2018. It is now read-only.

Conversation

as-cii
Copy link
Contributor

@as-cii as-cii commented Jan 15, 2018

Description of the Change

This pull request contains a few improvements to this package:

  • 26c77d4 relativizes all stack traces that originate from a file that is part of Atom Core. By doing so, we will eliminate duplicate entries on BugSnag that logically refer to the same code path.
  • bdd759e enhances existing tests and introduces new ones to ensure the normalization code path works correctly both when exceptions are triggered from Atom Core and when they aren't.
  • 764a883 addresses an issue discovered via the above tests that was preventing files outside of Atom Core from being normalized from /home-directory/foo/bar to ~/foo/bar, causing further duplication on BugSnag.

Alternate Designs

None.

Benefits

Prevents stack traces that logically belong to the same call site from being duplicated on BugSnag.

Possible Drawbacks

Unclear.

Applicable Issues

Fixes #35

@as-cii as-cii requested review from damieng and nathansobo January 15, 2018 17:37
@as-cii as-cii force-pushed the as-improve-path-normalization branch from 06ca06f to 7e5040a Compare January 15, 2018 17:44
lib/reporter.js Outdated
if (this.isBundledFile(absolutePath)) {
relativePath = path.relative(this.resourcePath, absolutePath)
} else {
const homeDirPath = fs.getHomeDirectory()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it might make more sense to make the home directory use forward slashes here rather than flip the relative path next.

lib/reporter.js Outdated
relativePath = absolutePath
.replace(/[/]/g, '\\') // Temp switch for Windows home matching
.replace(homeDirPath.replace(/[/]/g, '\\'), '~') // Remove users home dir
.replace(/.*(\/(app\.asar|packages\/).*)/, '$1') // Remove everything before app.asar or pacakges
Copy link
Contributor

Choose a reason for hiding this comment

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

pacakges should be packages - might as well correct that - was wrong previously too.

lib/reporter.js Outdated
return fileName.indexOf(atom.getLoadSettings().resourcePath) === 0
}
isBundledFile (fileName) {
return fileName.indexOf(this.resourcePath) === 0
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this ever worked on Windows - (or isTeletypeFile below) as atom.getLoadSettings().resourcePath is going to return an absolute Windows path, e.g. C:\Users\damie\AppData\Local\Atom x64\app-dev\resources\app.asar but we convert the filename into a linux style forward-slash one.

Ditto atom.packages.resolvePackagePath('teletype')

Copy link
Contributor

@nathansobo nathansobo left a comment

Choose a reason for hiding this comment

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

Once you work w/ Damien to get this working on Windows, it sounds like a big improvement. Thanks.

@as-cii as-cii force-pushed the as-improve-path-normalization branch from 0dbd996 to a880ce6 Compare January 17, 2018 14:54
The latter indicates the `app.asar` archive location, but stack trace
paths don't include the `.asar` extension.

Instead, with this commit we use `process.resourcesPath`, which is set
to a location that's one folder above `loadSettings.resourcePath`. This
allows to correctly identify files that are bundled.
@as-cii
Copy link
Contributor Author

as-cii commented Jan 17, 2018

This works as expected on macOS (and I assume on Linux too), see:

@damieng: can you do a smoke test on Windows to see if things work properly? Tests pass on AppVeyor, so I assume it will work correctly via a manual test too.

Once @damieng confirms this works properly on Windows, I think we should go ahead and 🚢. Thanks everyone for the help on this.

@damieng
Copy link
Contributor

damieng commented Jan 18, 2018

Are there any specific things you want me to try?

@as-cii
Copy link
Contributor Author

as-cii commented Jan 19, 2018

Are there any specific things you want me to try?

In my comment above I tested that:

  • Errors thrown from Teletype are reported to BugSnag and paths get cleaned up correctly.
  • Errors thrown from Atom Core are reported to BugSnag and paths get cleaned up correctly.

I think we should test similar things on Windows and then ship this. What do you think? Any other test you can think of for this pull request is definitely welcome! 👍

@as-cii as-cii merged commit 8fd1cdc into master Feb 6, 2018
@as-cii as-cii deleted the as-improve-path-normalization branch February 6, 2018 06:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants