diff --git a/sdks/rollbar.js/src/browser/core.js b/sdks/rollbar.js/src/browser/core.js index a4e0abaf6..bb02f692a 100644 --- a/sdks/rollbar.js/src/browser/core.js +++ b/sdks/rollbar.js/src/browser/core.js @@ -264,7 +264,9 @@ Rollbar.prototype.handleUncaughtException = function(message, url, lineno, colno // Chrome will always send 5+ arguments and error will be valid or null, not undefined. // If error is undefined, we have a different caller. - if (this.options.inspectAnonymousErrors && this.isChrome && (error === null)) { + // Chrome also sends errors from web workers with null error, but does not invoke + // prepareStackTrace() for these. Test for empty url to skip them. + if (this.options.inspectAnonymousErrors && this.isChrome && error === null && url === '') { return 'anonymous'; } diff --git a/sdks/rollbar.js/src/utility.js b/sdks/rollbar.js/src/utility.js index e64057cbb..83feaff45 100644 --- a/sdks/rollbar.js/src/utility.js +++ b/sdks/rollbar.js/src/utility.js @@ -358,8 +358,8 @@ function makeUnhandledStackInfo( }; location.func = errorParser.guessFunctionName(location.url, location.line); location.context = errorParser.gatherContext(location.url, location.line); - var href = document && document.location && document.location.href; - var useragent = window && window.navigator && window.navigator.userAgent; + var href = typeof document !== 'undefined' && document && document.location && document.location.href; + var useragent = typeof window !== 'undefined' && window && window.navigator && window.navigator.userAgent; return { 'mode': mode, 'message': error ? String(error) : (message || backupMessage),