这个问题只出现在生产阶段,开发阶段 - 就像一个魅力。
当用户尝试通过帮助程序生成的链接下载文件时:
<a href="{{fileRef.url download=true}}">Download</a>
在服务器端 node.js 失败并forever
重新启动它,并回显此错误:
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
我猜在客户端上只下载了部分文件——只有第一个块。我们尝试更改 nginx 反向代理缓存、缓冲区设置,甚至关闭 - 根本没有帮助。
知道如何修复,或者在哪里查找错误?非常感谢任何帮助。
集合初始化代码:
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'