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

Fetch API: net::ERR_ABORTED on Chrome #845

Closed
sogaani opened this issue Apr 6, 2018 · 0 comments
Closed

Fetch API: net::ERR_ABORTED on Chrome #845

sogaani opened this issue Apr 6, 2018 · 0 comments

Comments

@sogaani
Copy link
Contributor

sogaani commented Apr 6, 2018

I met fetch error, if i load gateway page.

api.js:368 GET https://sogaani-test.mozilla-iot.org/settings/experiments/speech net::ERR_ABORTED
getExperimentSetting @ api.js:368
getExperimentSetting @ menu.js:39
init @ menu.js:29
init @ app.js:49
app_onLoad @ app.js:111
load (async)
(anonymous) @ app.js:109
  • Server
    Linux: DESKTOP-93GMCH3 4.4.0-43-Microsoft Adapter API #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux
    Node: v8.9.4

  • Client
    Windows 10
    Chrome version 65.0.3325.181(Official Build) (64 bit)

I thought that this issue relates ReadableStream.
We do not get body, if getExperimentSetting get 404. And, maybe data left on ReadableStream.

I modify code as follows and it works fine.

    getExperimentSetting: function(experimentName) {
      const headers = {
        Authorization: `Bearer ${window.API.jwt}`,
        Accept: 'application/json',
      };
      return fetch(
        `/settings/experiments/${encodeURIComponent(experimentName)}`, {
          method: 'GET',
          headers: headers,
        })
        .then(function(response) {
          if (!response.ok) {
            // If do not get body, met net::ERR_ABORTED on chrome.

            if (response.body && response.body.cancel) {
              response.body.cancel();
            }
            throw new Error(`Error getting ${experimentName}`);
          }

          return response.json()
            .then(function(json) {
              return json.enabled;
            }).catch(function(e) {
              throw new Error(`Error getting ${experimentName} ${e}`);
            });
        });
    },

We can fix this error, but I'm not sure if this error will do something bad.

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

No branches or pull requests

3 participants