Skip to content

null check stacks in isSameStacktrace #1339

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

uforic
Copy link

@uforic uforic commented May 29, 2018

Description

Some libraries, such as Mapbox, throw errors that are malformed. They don't have the frames variable, which get used in "_isRepeatData".

This causes Raven.captureException to fail on the second call, on _isRepeatData when deduping errors. This is particularly nasty because it's occurring in the catch part of a try / catch.

Sample code:

    try {
      const attemptedMap = new mapboxgl.Map({
        container: this.mapRef.current,
        style: this.getMapStyle(),
        center: initialCenter,
        zoom: initialZoom,
      });
 } catch (e) {
      // error thrown here
      Raven.captureException(e, {
        level: "warning",
        stacktrace: true});
}

Exception seen in FullStory:

TypeError: Cannot read property 'length' of undefined at d (vendor.bd501d31eb3dbf1fd2b5.js:23:30798) at s._isRepeatData (vendor.bd501d31eb3dbf1fd2b5.js:23:25059) at s._sendProcessedPayload (vendor.bd501d31eb3dbf1fd2b5.js:23:26662) at s._send (vendor.bd501d31eb3dbf1fd2b5.js:23:26417) at s._processException 

I'm not sure what the preferred behavior is here (returning true or false), but it strikes me that returning false is safer.

Appreciate any feedback, thanks!

@uforic uforic requested a review from kamilogorek as a code owner May 29, 2018 17:29
@kamilogorek
Copy link
Contributor

Looks good. Could you also add a quick test covering this scenario? (I also just realized that we don't have tests for this util at all...)

@@ -3,7 +3,11 @@ var stringify = require('../vendor/json-stringify-safe/stringify');
var _window =
typeof window !== 'undefined'
? window
: typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
: typeof global !== 'undefined'
Copy link
Author

Choose a reason for hiding this comment

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

The lint script runs prettier automatically, and it did this to the file.

I verified in my yarn.lock that I'm on the correct prettier version; I can skip the lint step if you'd prefer and return this to it's normal formatting if y'all are getting different behavior, just let me know.

@uforic
Copy link
Author

uforic commented Jun 6, 2018

@kamilogorek - yep, wrote tests, and checks pass. Let me know if you need anything else!

@kamilogorek
Copy link
Contributor

Rebased and merged manually. Thanks!

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