title: I am getting the Heroku H12 - Request timeout error for no apparent reason
body: <p>In my parse server I have a class called <code>Stats</code> which contains the column <code>timeScore</code> (number)</p>
  
  <p>I am using cloud code to update all 250k rows in the column <code>timeScore</code>. </p>
  
  <p>My code works well except for the fact that I get the following H12 - Request timeout error for no apparent reason.</p>
  
  <pre><code>heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/parse/functions/timeScore
  </code></pre>
  
  <p>I get the timeout error regardless of what batchSize I choose and I get it every 30 seconds. I get it for a total of 5 times. After the 5th time I dont get it anymore and the process continues and finishes without any issues or errors. I get the 5th and last error at around 2.5 minutes into the process (30seconds*5).The whole process takes about 14 minutes. These timeout errors does not effect the process in any way. All 250k objects are updated and saved regardless of the selected batchSize and despite the timeout errors.</p>
  
  <p>I thought maybe because I never call <code>results.error</code> or <code>results.success</code> the server thinks I am still doing some work and shows the error. However I updated my code as seen below to include them and I still get the timeout errors.</p>
  
  <p>The problem is after each timeout error <code>processBatch()</code> is called once again from the beggining. Since I get 5 timeout errors <code>processBatch()</code> gets called 5 times. So after the 5th timeout error there are 5 <code>processBatch()</code> functions running simultaneously (I confirmed this with logs). This makes the process take much longer that it should take.</p>
  
  <p>I am not performing any long running actions. I am just updating and saving data on my parse server.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>var _ = require("underscore");
  Parse.Cloud.define("timeScore", function(request, response) {
  var counter = 0;
  function processBatch(query, batchSize, startingAt, process) {
      query.limit(batchSize);
      query.skip(startingAt);
  
      return query.find().then(results =&gt; {
  
          return process(results).then(() =&gt; results.length);
      }).then(length =&gt; {
  
          return (length === batchSize)? processBatch(query, batchSize, startingAt+length, process) : {};
      });
  }
  
  function setTimeScores(stats) {
          console.log("LENGTH " + stats.length);
      _.each(stats, stat =&gt; {
  
          counter ++;
          stat.set("timeScore", counter);
  
      });
      return Parse.Object.saveAll(stats);
  }
  
  var query = new Parse.Query("Stats");
  
  processBatch(query, 1000, 0, setTimeScores).then(results =&gt; {
          response.success(results);
      }).catch(error =&gt; {
          response.error(error);
      });
  
  });
  </code></pre>
  
  <p>Here is how I call it</p>
  
  <pre><code>#!/usr/bin/env node
  var Parse = require("parse/node");
  Parse.initialize("xx",   "xx");
  Parse.serverURL = "http://randomapp.herokuapp.com/parse";
  Parse.Cloud.run('timeScore');
  </code></pre>
  
  <p>What is causing the heroku timeout errors I am getting? How do I fix it? </p>