title: Unexpected meteorjs error Can't render headers after they are sent to the client
body: <pre><code>http.js:732
      throw new Error('Can\'t render headers after they are sent to the client.'
      ^
  Error: Can't render headers after they are sent to the client.
      at ServerResponse.OutgoingMessage._renderHeaders (http.js:732:11)
      at ServerResponse.writeHead (http.js:1153:20)
      at ProxyServer.&lt;anonymous&gt; (/home/ec2-user/.meteor/packages/meteor-tool/.1.1.4.1tjewoi++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/tools/run-proxy.js:96:21)
      at ProxyServer.emit (/home/ec2-user/.meteor/packages/meteor-tool/.1.1.4.1tjewoi++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/http-proxy/node_modules/eventemitter3/index.js:100:27)
      at ClientRequest.proxyError (/home/ec2-user/.meteor/packages/meteor-tool/.1.1.4.1tjewoi++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:140:16)
      at ClientRequest.emit (events.js:117:20)
      at Socket.socketOnData (http.js:1593:9)
      at TCP.onread (net.js:528:27)
  </code></pre>
  
  <p>Meteor server throws this error or Production instance only. I'm running the same repository in Staging and it runs smoothly. Meteor throws this error even when nobody is interacting with the client (Crons run on server during regular intervals). I'm not able to figure out the reason. People have faced this problem for different issues, but I didn't find it familiar with my case. </p>
  
  <p>I suspect this code is throwing this error. Not sure though </p>
  
  <pre><code>updateFunction = function(event) {
      var res =  Meteor.http.call("GET", "http_url"+ event);
      var contents = EJSON.parse(res.content).tracks["0"];
      if(!contents) return;
      var events = [];
      contents.map(function(ele){
              if(ele.type == "snap") {
                  ele._id = ele.id;
                  delete ele.id;
                  events.push(ele);
              }
      });
      CollectionName.upsert(event,{"$set":{"data": events}});
  }
  </code></pre>