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

NS_ERROR_FAILURE XMLHttpRequest exception #2809

Closed
mrf345 opened this issue Jan 12, 2019 · 9 comments
Closed

NS_ERROR_FAILURE XMLHttpRequest exception #2809

mrf345 opened this issue Jan 12, 2019 · 9 comments

Comments

@mrf345
Copy link

mrf345 commented Jan 12, 2019

Hello there, I'm new to mootools so bear with me please :)
I'm having a strange issue while E2E testing. I'm using mootools 1.4.0 with Firefox 45.0.1
While attempting XMLHttpRequest this exception gets raised:

Exception { message: "", result: 2147500037, name: "NS_ERROR_FAILURE", filename: "http://127.0.0.1:8000/mootools.js", lineNumber: 5706, columnNumber: 0, data: null, stack: "this.Request<.send@http://127.0.0.1:8000/mootools.js:5706:13wrap/wrapper<@http://127.0.0.1:8000/smootools.js:1646:22Request<.initialize/this.send@http://127.0.0.1:8000/mootools.js:9997:18ReqJSON.send" }

I did try catch to pass the test error free for now. Thanks in advance 👍

@swhiteman
Copy link

Please show the code you're using that's "attempting XMLHttpRequest". You've only shown the exception.

What resource are you trying to get/head/post? Is it on the same origin as your main document?

@mrf345
Copy link
Author

mrf345 commented Jan 13, 2019

@swhiteman Thanks for the prompt replay 👍
I don't get the whole picture myself, but the general idea is: I have a huge model that contains a time-out function that handles updating items, so it will make the XMLHttpRequest then updates the items:

toggleItems: function () {
    var self = this;
    if (gotTimedOut) clearTimeout(gotTimedOut)
    gotTimedOut = setTimeout(function () {
        self.retrieveItems(self.filterItems(self))
        // retrieveItems will do the XMLHttpRequest with req-json and sort out the items
    })
}
retrieveItems: function (filteredItems) {
    // do some sorting of existing items
    var req = new ReqJSON({
            'async': false,
            'url': window.location + 'someEndPoint',
            'onSuccess': callback
    }).send(JSON.encode(theDataToSubmit))
    // do some more filtering
}

The exception showed before leads to this chunk of mootools.js:

this.fireEvent('request');
xhr.send(data);
if (!this.options.async) this.onStateChange();
if (this.options.timeout) this.timer = this.timeout.delay(this.options.timeout, this);
return this;

Interesting warning message i got from mootools.js before the exceptions was raised:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help http://xhr.spec.whatwg.org/

While debugging i tried to resend the data and got this exception:

[Exception... "Component not initialized"  nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)"  location: "JS frame :: debugger eval code :: <TOP_LEVEL> :: line 1"  data: no]

@swhiteman
Copy link

But you still haven't included the relevant information about the main document's origin and the XHR destination's origin.

The common sync XHR warning does not itself stop a request from going out but that doesn't mean a CORS response can be processed.

@mrf345
Copy link
Author

mrf345 commented Jan 13, 2019

My bad, i'm trying to post on the same origin. the request stoped and the first exception got raised.

@swhiteman
Copy link

Do you have a live repro of this problem (CodePen, jsFiddle, et al.)?

@mrf345
Copy link
Author

mrf345 commented Jan 13, 2019

No i don't. I've encountered it during E2E testing on a local dev environment.

@swhiteman
Copy link

I guess you'll have to work toward a public repro case.

Curious if you get the same result with the well-known port for HTTP (TCP 80). What about with GET? And are you absolutely sure the XHR is being sent to the same origin (protocol + hostname + port)?

@mrf345
Copy link
Author

mrf345 commented Jan 13, 2019

I will try setting up one later.
I'm sure of the same origin as it is attempting to post to window.location.href + ....
Good idea i'll try get instead, and try running the test on chrome too.

Thanks a lot @swhiteman

@mrf345
Copy link
Author

mrf345 commented Jan 16, 2019

Turns out it was an authentication issue with the post request.
Thanks, and sorry for wasting your time @swhiteman .

@mrf345 mrf345 closed this as completed Jan 16, 2019
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

No branches or pull requests

2 participants