Skip to content

Strip Raven's wrapped try/catch call from frames [WIP] #581

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

Closed
wants to merge 1 commit into from

Conversation

benvinegar
Copy link
Contributor

When users see try/catch in their stack traces, they believe the bug is Raven's fault (read: ours).

This patch makes it so that the correct number of frames are sliced from the top of the frames array before being sent to Sentry.

This also means that wrapped functions should now produce the same results as strictly doing window.onerror. This makes it possible for us to remove function instrumentation from modern browsers that support a fully-functioning window.onerror (which we can feature detect).

cc @mattrobenolt @mitsuhiko

// If not an Error is passed through, recall as a message instead
if (!isError(ex)) return this.captureMessage(ex, options);
if (!isError(ex)) return this.captureMessage(ex, options, skipframes + 1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Err, this isn't necessary ... yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, by incrementing and passing skipframes to captureMessage, we can generate a new stack by throwing an error from inside captureMessage, slice off skipframes frames, and then we can send that w/ the payload to Sentry. As in, we can now attach valid stack traces alongside captureMessage calls.

I was going to do that in a separate PR.

@benvinegar
Copy link
Contributor Author

Alternatively we could keep the frame, but tag it as in_app so that it doesn't affect fingerprinting or appear in the UI in the default stack view.

@mitsuhiko
Copy link
Contributor

@benvinegar why do we not just completely remove all frames that originate in raven-js?

@benvinegar
Copy link
Contributor Author

@mitsuhiko – If you mean, why don't we identify them as being from raven-js via the culprit/filename, the problem is that we cannot reliably identify our frames when the code is minified, which most raven-js users are doing.

We could potentially do this, on the server, after source maps have been applied ... but not everyone uses source maps. I also wouldn't make such a change until we move stack trace parsing onto the server.

But you did just tip me off to a problem: Raven.wrap is a public API method, and it could be used in places where it is NOT the top-most frame ... meaning we'll kill the wrong frame. To fix this, we'd need a dedicated "asyncWrap" function or something.

@mattrobenolt
Copy link
Contributor

Mark as in_app = False

@benvinegar
Copy link
Contributor Author

This was partially implemented in #582

@benvinegar benvinegar closed this Nov 18, 2016
@benvinegar benvinegar deleted the skipframes branch February 28, 2017 01:57
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.

3 participants