title: Meteor's CollectionFS download Error: write after end
body: <p><em>This issue appears only on production stage, development stage - works like a charm.</em></p>
  
  <p>When user tries to download the file by link generated via helper:</p>
  
  <pre><code>&lt;a href="{{fileRef.url download=true}}"&gt;Download&lt;/a&gt;
  </code></pre>
  
  <p>On server side node.js is fails and <code>forever</code> restarts it, with echoing this error:</p>
  
  <pre><code>Error: write after end
     at ServerResponse.OutgoingMessage.write (_http_outgoing.js:413:15)
     at ServerResponse.http.OutgoingMessage.write (packages/meteorhacks:inject-data/lib/server.js:56:1)
     at ServerResponse.res.write (/var/node/bundle/programs/server/npm/webapp/node_modules/connect/lib/middleware/compress.js:110:17)
     at ServerResponse.res.end (/var/node/bundle/programs/server/npm/webapp/node_modules/connect/lib/middleware/compress.js:116:14)
     at sendResponseIfDone (packages/cfs:http-methods/http.methods.server.api.js:543:1)
     at IncomingMessage.&lt;anonymous&gt; (packages/cfs:http-methods/http.methods.server.api.js:568:1)
     at IncomingMessage.emit (events.js:104:17)
     at _stream_readable.js:908:16
     at process._tickCallback (node.js:355:11)
  error: Forever detected script exited with code: 1
  error: Script restart attempt #1
  </code></pre>
  
  <p>On the client the file downloaded only partly, I guess - only first chunk.
  We've tried to change nginx reverse-proxy caching, buffers settings, even turn the off - doesn't help at all.</p>
  
  <p>Any idea how to fix, or where to look for errors? Any help is very appreciated.</p>
  
  <p>Collection init code:</p>
  
  <pre><code>path = (if (NODE_ENV is "development") then "/uploads/Addresses" else "/builded/bundle/programs/server/assets/app/uploads/Addresses")
  
  Collections.Addresses = new FS.Collection 'Addresses', 
     stores: [ 
        new FS.Store.FileSystem 'Addresses' ,
          path: path
     ]
  ,
    filter: 
      allow: 
        extensions: ['xls', 'xlsx']
  
  if Meteor.isServer
    Meteor.startup -&gt;
      Collections.Addresses.allow
        insert: (userId) -&gt;
          return checkFunc userId
        remove: (userId) -&gt;
          return checkFunc userId
        update: (userId) -&gt;
          return checkFunc userId
        download: (userId) -&gt;
          return checkFunc userId
  
    Meteor.publish 'Addresses', (ProjectID) -&gt;
      check ProjectID, Mongo.ObjectID
  
      if checkFunc this.userId
        Collections.Addresses.find 
          'metadata.project_id': ProjectID
      else
        throw new Meteor.Error 403, 'Permission denied'
  </code></pre>