title: Fetch throws "TypeError: Failed to fetch" for successful, same-origin request
body: <p>We have been encountering inconsistent client errors with a single-page JavaScript application making fetch requests. Of note, they are all <em>same-origin</em> requests.</p>
  
  <pre><code>let request = new Request(url, options);
  ...
  window.fetch(request)
    .then(response =&gt; response.json())
    .then(data =&gt; ...)
    .catch(error =&gt; ...)
  </code></pre>
  
  <p>Around 5% of the promises are rejecting with the following error despite the server and the browser receiving a <code>200 OK</code> response:</p>
  
  <pre><code>TypeError: Failed to fetch
  </code></pre>
  
  <p>I'm stumped... All of my searches lead to discussions about CORS errors. That doesn't seem to apply given these are all same-origin requests. What is causing the fetch to throw the <code>TypeError</code>?</p>
  
  <p>I can confirm using the Network tab in Chrome DevTools that the fetch request completes with a <code>200 OK</code> response and valid JSON. I can also confirm that the URLs are same-origin. I can also confirm that there are no CORS pre-flight requests. I have reproduced this issue on Chrome 66 and Safari 11.1. However, we've received a stream of error reports from a mix of Chrome and Safari versions, both desktop and mobile.</p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>This does not appear to be a duplicate of the linked question as we are <em>not</em> sending CORS requests, <em>not</em> setting <code>mode: "no-cors"</code>, and <em>not</em> setting the <code>Access-Control-Allow-Origin</code> header.</p>
  
  <p>Additionally, I re-ran tests with the <code>mode: 'same-origin'</code> option set explicitly. The requests are (still) successful; however, we (still) receive the intermittent <code>TypeError</code>.</p>