This issue appears only on production stage, development stage - works like a charm.
When user tries to download the file by link generated via helper:
<a href="{{fileRef.url download=true}}">Download</a>
On server side node.js is fails and forever
restarts it, with echoing this error:
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.<anonymous> (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
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.
Any idea how to fix, or where to look for errors? Any help is very appreciated.
Collection init 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 ->
Collections.Addresses.allow
insert: (userId) ->
return checkFunc userId
remove: (userId) ->
return checkFunc userId
update: (userId) ->
return checkFunc userId
download: (userId) ->
return checkFunc userId
Meteor.publish 'Addresses', (ProjectID) ->
check ProjectID, Mongo.ObjectID
if checkFunc this.userId
Collections.Addresses.find
'metadata.project_id': ProjectID
else
throw new Meteor.Error 403, 'Permission denied'
@tristan-foureur Thank you for response. But we're stuck with this package, also it's dramatically slow down our app, doesn't support non-latin symbols in filename and has limits on big files upload/download.
We spent two weeks for research and create our own package: Meteor-Files. It's sleek and easy to use. Your hands is untied, you're free to do anything with uploaded file(s), modify, resize images, even store to GridFS if you wish so.
We're hope our package will help to solve simple task as upload/download files to other developers. Meteorites unite!