title: xmlhttprequest on google chrome, sometimes return net::connection_reset error
body: <p>i've been tasked create a xhr post request to websocket server,</p>
  
  <p>however whenever chrome is used, it returns net::ERR_CONNECTION_RESET 50% of the time.  </p>
  
  <p>this does not occurs on other browser as tested on safari, firefox, and microsoft edge.</p>
  
  <pre><code>function doPost(url, data) {
      promisePost(url, data)
      .then(
          function (val) {
              console.log("returns: " + val);
  
          }, function (error) {
              console.log("error: " + error);
          })
  };
  
  var promisePost = function (url, data) {
       return new Promise(function (resolve, reject) {
          try {
              var xhr = new XMLHttpRequest();
  
              xhr.upload.onabort = function () {
                  reject("aborted by user");
              };
  
              xhr.timeout = 5000;
  
              xhr.ontimeout = function () {
                  reject("error@timeout");
              };
  
              var handleStateChange = function () {
  
                  switch (xhr.readyState) {
  
                      case 4:
                          //responses
                          if (xhr.status == 0) {
                              //undefined error it return xhrstatus 0
                              reject("error@xhrcode:" + xhr.status);
                          } else {
                              if (xhr.responseText == "") {
                                  reject("error@response is empty");
                              } else
                                  resolve("done@xhrcode:" + xhr.status + "@responses:" + xhr.responseText);
                          }
                          break;
                      default:
                          //error with statuscode
                          reject("error@xhrcode:" + xhr.status + "@responses:" + xhr.responseText);
                  };
              };
  
              xhr.onerror = function (e) {
                  reject("status code: " + xhr.status + " " + e);
              };
              xhr.onreadystatechange = handleStateChange;
              xhr.open("POST", url, true);
              xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
              xhr.send(data);
  
          } catch (e) {
              //error in script
              reject("scerror " + e.message);
          }})
  };
  </code></pre>
  
  <p>i'm 100% certain that the server already have cors support since i've been testing it via other browser.</p>
  
  <p>anyone got any idea how to solve this? been stuck on this for past 3 weeks</p>