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

"Failed to load response data" in chrome #83

Closed
nhagen opened this issue Jan 28, 2015 · 12 comments
Closed

"Failed to load response data" in chrome #83

nhagen opened this issue Jan 28, 2015 · 12 comments

Comments

@nhagen
Copy link

nhagen commented Jan 28, 2015

I'm getting a "Failed to load response data" error in chrome. When I chrome inspect afterxhr.responseType = 'blob', xhr.responseText immediately becomes the following:

[Exception: DOMException: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'blob').]

When I change it xhr.responseType = '' the problem goes away.

Here are the http headers:

Remote Address:127.0.0.1:3000
Request URL:http://localhost:3000/api/Orders
Request Method:GET
Status Code:200 OK

Request Headers
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Host:localhost:3000
Origin:http://localhost:8080
Pragma:no-cache
Referer:http://localhost:8080/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36

Response Header
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http://localhost:8080
Connection:keep-alive
Content-Length:32
Content-Type:application/json; charset=utf-8
Date:Wed, 28 Jan 2015 04:27:25 GMT
ETag:W/"20-c4c67a6b"
Vary:Origin, Accept-Encoding
X-Powered-By:Express

There is no problem in FF. I'm using fetch via the flux Martyjs library. Could this be a problem with my API endpoint? Can anyone provide any insight into this, or reproduce it?

Let me know what I can provide to be more constructive here.

@dgraham
Copy link
Contributor

dgraham commented Jan 28, 2015

We always set responseType to blob, which doesn't seem right. Introduced in #60.

@josh

@josh
Copy link
Contributor

josh commented Jan 28, 2015

We always set responseType to blob, which doesn't seem right.

Thats definitely what we want to do, but it sounds like responseText is incorrectly being accessed somehow instead of the general response type.

@josh
Copy link
Contributor

josh commented Jan 28, 2015

@nhagen can you post more to reproduce this example.

@nhagen
Copy link
Author

nhagen commented Jan 28, 2015

I'm able to isolate this just using marty, but it is resolvable as described above.

Following the getting started guide here: http://martyjs.org/guides/getting-started/

npm install -g yo generator-marty
mkdir example && cd example
yo marty
yo marty:domain user
npm start
open http://localhost:5000/user/134 in chrome

Inspecting the api call to http://localhost:5000/api/users/134 yields Failed to load response data. I did not initially find this after using the yeoman generator, so i was able to get this in my own code and in the autogenerated code.

I'm creating an issue in martyjs in case its a problem with that library at this point. martyjs/marty#90

@msokk
Copy link

msokk commented Feb 2, 2015

Also to note, there is a Chrome devtools bug about not showing blob type XHR's response in Network tab -
https://code.google.com/p/chromium/issues/detail?id=412401

Example: http://jsfiddle.net/ysangkok/sJxXk/86/

@adamschoenemann
Copy link

I'm having the same exact problem. The chrome issue appears closed, yet the bug still remains.

@msokk
Copy link

msokk commented Feb 5, 2015

I think it is not released to stable yet. Chrome Canary works.

@adamschoenemann
Copy link

Ah, thanks! Chrome Canary works.

@josh
Copy link
Contributor

josh commented Feb 12, 2015

Closing out since this is not an issue with this library.

@josh josh closed this as completed Feb 12, 2015
@WangYang-Rex
Copy link

I'm having the same exact problem!

@bofcarbon1
Copy link

I am running an Angular 4 UI compile with webpack and I just upgraded to zone.js 0.8.4. Got the 'net ERR CONNECTION REFUSED error but only in Google Chrome browser. When I used IE I have no problems.

The zone.js code and error....

start of code....

function scheduleTask(task) {
    XMLHttpRequest[XHR_SCHEDULED] = false;
    var data = task.data;
    // remove existing event listener
    var listener = data.target[XHR_LISTENER];
    if (listener) {
        data.target.removeEventListener('readystatechange', listener);
    }
    var newListener = data.target[XHR_LISTENER] = function () {
        if (data.target.readyState === data.target.DONE) {
            // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with
            // readyState=4 multiple times, so we need to check task state here
            if (!data.aborted && XMLHttpRequest[XHR_SCHEDULED] && task.state === 'scheduled') {
                task.invoke();
            }
        }
    };
    data.target.addEventListener('readystatechange', newListener);
    var storedTask = data.target[XHR_TASK];
    if (!storedTask) {
        data.target[XHR_TASK] = task;
    }
    sendNative.apply(data.target, data.args);  ///' error message Failed to load resource: net::ERR_CONNECTION_REFUSED  ////
    XMLHttpRequest[XHR_SCHEDULED] = true;
    return task;
}

end of code.............

I don't even know what the scheduled task would be or why zone.js is processing this XHR TASK for data.
My observable calls are in an injected service and they are the only way that I pass Json data back and forth through http request/responses. All this works fine. Can't figure out why this task attempt is made with no data on Google Chrome.

Repository owner locked and limited conversation to collaborators Oct 19, 2017
@dgraham
Copy link
Contributor

dgraham commented Oct 19, 2017

Stack Overflow is the best place to ask browser usage questions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants