TypeError in _trimBreadcrumbs where `crumb.data` exists but is undefined
svanzoest opened this issue · comments
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.