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

Capture NS_ERROR_FAILURE errors from Firefox #528

Merged
merged 1 commit into from
Mar 16, 2016
Merged

Conversation

benvinegar
Copy link
Contributor

I've managed to reproduce these failures by trying to do a POST from an html page that is served from the local filesystem (e.g. file:///)

var request = new XMLHttpRequest();
request.open("POST", 'http://example.com', false);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.send('');

Unfortunately I cannot write a test for this without overwriting Object.prototype.toString.call. Maybe that's worthwhile anyways.

Example of a stack captured after this change:

{
    "project": "1",
    "logger": "javascript",
    "platform": "javascript",
    "request": {
        "headers": {
            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:44.0) Gecko/20100101 Firefox/44.0"
        },
        "url": "file:///Users/xxx/Projects/sentry/index.html"
    },
    "exception": {
        "values": [{
            "type": "NS_ERROR_FAILURE",
            "value": "",
            "stacktrace": {
                "frames": [{
                    "filename": "file:///Users/xxx/Projects/sentry/index.html",
                    "lineno": 12,
                    "colno": 1,
                    "function": "?",
                    "in_app": true
                }, {
                    "filename": "[2]</Raven.prototype._wrapBuiltIns/</<@http://127.0.0.1:8002/dist/raven.js",
                    "lineno": 703,
                    "colno": 28,
                    "function": "?",
                    "in_app": false
                }]
            }
        }]
    },
    "culprit": "[2]</Raven.prototype._wrapBuiltIns/</<@http://127.0.0.1:8002/dist/raven.js",
    "message": "NS_ERROR_FAILURE: ",
    "extra": {
        "session:duration": 83
    },
    "event_id": "7784426458894fe4bd595d44505f3ec2"
}

@@ -28,6 +28,7 @@ function isEmptyObject(what) {
function isError(what) {
return isObject(what) &&
objectPrototype.toString.call(what) === '[object Error]' ||
objectPrototype.toString.call(what) === '[object Exception]' || // Firefox NS_ERROR_FAILURE Exceptions
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just do:

['[object Error]', '[object Exception]'].indexOf(objectPrototype.toString.call(what)) > -1

Then we only need to toString() once and if we need to add to this, just add to this array. This array could also be popped out into a constant for like, var ERROR_TYPES = ['[object Error]', '[object Exception]']

Other than this, seems reasonable.

@benvinegar
Copy link
Contributor Author

IE8 doesn't have Array.prototype.indexOf.

I'll make an update – we don't need to get that fancy.

@mattrobenolt
Copy link
Contributor

IE8 doesn't have Array.prototype.indexOf.

TIL

Ignore me then. :)

@benvinegar
Copy link
Contributor Author

Note that we still don't parse out the frame correctly – these NS errors have a different stack format than regular Firefox errors.

@benvinegar
Copy link
Contributor Author

I still think we can move ahead with accepting this though, since most frames will still be read correctly.

benvinegar added a commit that referenced this pull request Mar 16, 2016
Capture NS_ERROR_FAILURE errors from Firefox
@benvinegar benvinegar merged commit 29b52da into master Mar 16, 2016
@benvinegar benvinegar deleted the fix-ns-error branch March 16, 2016 05:07
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.

None yet

2 participants