title: XHR request -> getting ERR_EMPTY_RESPONSE
body: <p>I'm trying to make a fetch request that takes a long time (2-5m), but I'm getting this error message in the Chrome console after around 1m30:</p>
  
  <blockquote>
    <p>Failed to load resource: net::ERR_EMPTY_RESPONSE</p>
  </blockquote>
  
  <p>So, I tried to wrap my XHR request in a timer, like that:</p>
  
  <blockquote>
    <p>client-side code:</p>
  </blockquote>
  
  <pre><code>xhr.open('GET', '/refresh', true); 
  xhr.timeout = 600000; 
  xhr.onload = function () { 
     window.location.reload(); 
  }; 
  xhr.send(null);
  </code></pre>
  
  <blockquote>
    <p>server-side code:</p>
  </blockquote>
  
  <pre><code>app.get("/refresh", (req, res) =&gt; {    
      var process = spawn('python3', ["scrape.py"]);
      process.stdout.on('data', function (data){
          console.log("-&gt; " + data.toString());
          if ((data.toString().indexOf("done") &gt; -1)) {
              res.json({done: "done"});
          }
      });
  });
  </code></pre>
  
  <p><strong>But I'm still getting the same error after around 1m30, and also the console log 'TIMEOUT'.. Why?</strong></p>
  
  <p>If I run the exact same code with a Python script that lasts 20 seconds, it works perfectly.</p>
  
  <p>Thanks</p>