Skip to content

Combine exception stacks lazily where possible #1

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 2 commits into from
Feb 3, 2016

Conversation

glenjamin
Copy link
Contributor

This is a bit wacky, but I figured I'd send in the PR and see what you think.

I did a big survey of error / exception libs I could find on npm today, and this one ticked the boxes I was looking for - attaching arbitrary data, and concatenating stack traces together.

One thing I was hoping to find was a lib which only attached the stack traces together if the .stack property is read - especially on v8 where this property is lazily calculated.

This PR attempts to detect if this is possible in the executing runtime, and then does so.

Passes tests on Karma and Node locally, but there might be something I've missed still

@JamesMessinger
Copy link
Member

Omigod that rocks! Great idea. I'll do some testing of my own and maybe even add some new tests to specifically cover this, but yes, I'll be glad to merge this PR.

@JamesMessinger
Copy link
Member

Actually... I may not have the time to get to this myself for a week or two. So why wait? :)

Would you mind adding a test case to hit this line of code? It's the only branch that's not currently covered. If you'll do that, I'll merge the PR ASAP

@glenjamin
Copy link
Contributor Author

Is the coverage only from node?

I can patch a global to simulate the fallback to hit that case.

@JamesMessinger
Copy link
Member

The coverage data includes node and browsers. (all the lcov.info files are concatenated together)

However, I just noticed that I only have KARMA_COVERAGE=true set for one of the CI builds, and that buid only includes Firefox and PhantomJS. Try setting KARMA_COVERAGE=true for the SauceLabs build. That build covers all browsers, so maybe one of them will hit that line of code.

@glenjamin
Copy link
Contributor Author

I'm fairly sure firefox should hit that line, i'll give it a go.

@glenjamin glenjamin force-pushed the lazy-stack-concat branch 3 times, most recently from 8e0026b to b906674 Compare February 2, 2016 20:31
@glenjamin
Copy link
Contributor Author

That's all passing now and executing the line from before (older versions of firefox made .stack a property descriptor that wasn't lazy)

As part of these changes I broke a long line up and because this is line coverage and not branch coverage, it's not getting hit any more.

The line in question is https://coveralls.io/builds/4946993/source?filename=lib%2Findex.js#L192 which can only be hit if Object.getOwnPropertyDescriptor && Object.defineProperty is false.

This is only needed for IE8 support - is that a goal?

@JamesMessinger
Copy link
Member

IE8 support isn't necessary, but it doesn't hurt to leave that line in there just in case. I'm ok with it not being hit.

Thanks for all your work! Merging in 3... 2... 1...

JamesMessinger added a commit that referenced this pull request Feb 3, 2016
Combine exception stacks lazily where possible
@JamesMessinger JamesMessinger merged commit a3b2cc6 into JS-DevTools:master Feb 3, 2016
@JamesMessinger
Copy link
Member

Onoes! The tests are failing on Android due to the _error property that gets added by the extendStackProperty() method.

I'll make a quick change to avoid adding that property.

@glenjamin
Copy link
Contributor Author

Thanks! Do the android tests only run on the main branch?

@JamesMessinger
Copy link
Member

I have no idea why the Android tests didn't fail on the PR branch. They appear to have run successfully there. No clue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants