Skip to content
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

TypeError in _trimBreadcrumbs where crumb.data exists but is undefined #925

Closed
svanzoest opened this issue Apr 7, 2017 · 0 comments · Fixed by #929
Closed

TypeError in _trimBreadcrumbs where crumb.data exists but is undefined #925

svanzoest opened this issue Apr 7, 2017 · 0 comments · Fixed by #929

Comments

@svanzoest
Copy link

What is the current behavior?

It seems to be that there is a situation where https://github.com/getsentry/raven-js/blob/3.14.0/src/raven.js#L1358-L1359

    _trimBreadcrumbs: function (breadcrumbs) {
        // known breadcrumb properties with urls
        // TODO: also consider arbitrary prop values that start with (https?)?://
        var urlprops = {to: 1, from: 1, url: 1},
            crumb,
            data;

        for (var i = 0; i < breadcrumbs.values.length; i++) {
            crumb = breadcrumbs.values[i];
>            if (!crumb.hasOwnProperty('data'))
>               continue;

            data = crumb.data;
            for (var prop in urlprops) {
>                if (data.hasOwnProperty(prop)) {
                    data[prop] = truncate(data[prop], this._globalOptions.maxUrlLength);
                }
            }
        }
    },

Does not seem to catch crumb.data where it exists but is undefined. This causes the browser to exhibit the following in my Chrome 57.0.2987.133 console.log.

Fetch API cannot load https://api.domain.com/1/resource. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://example.domain.com' is therefore not allowed access. The response had HTTP status code 401. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

vendor.d6f6b2b….js:1
Uncaught TypeError: Cannot read property 'hasOwnProperty' of undefined
at i._trimBreadcrumbs (vendor.d6f6b2b….js:1)
at i._trimPacket (vendor.d6f6b2b….js:1)
at i._sendProcessedPayload (vendor.d6f6b2b….js:1)
at i._send (vendor.d6f6b2b….js:1)
at i._processException (vendor.d6f6b2b….js:1)
at i._handleStackInfo (vendor.d6f6b2b….js:1)
at i.captureException (vendor.d6f6b2b….js:1)
at a (app.3b3d78964d8bfab1c109.js:1)
at b.onunhandledrejection (app.3b3d78964d8bfab1c109.js:1)
vendor.d6f6b2b….js:1

This seems to be related to the further down the line if (data.hasOwnProperty(prop)) { which causes the Uncaught TypeError: Cannot read property 'hasOwnProperty' of undefined

This issue seems to be introduced by 3.14.0 on Chrome 57.0.2987.133 on MacOS 10.12.3 (16D32), which is build into a vendor.js via webpack2.

The expected behavior is the raven client to not cause a TypeError by tempting to access a property of an undefined object.

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 a pull request may close this issue.

1 participant