While using the .serve() method to serve a request stream, if a user aborts the download from the browser Meteor crashes on the server.
This is my code, used in the interceptDownload hook:
this.serve(http, fileRef, fileRef.versions[version], version, request({
url: path,
headers: headers
}));
When I cancel the download from the browser I get this error:
W20171201-20:45:10.943(1)? (STDERR) meteor://馃捇app/packages/ostrio_files.js:2112
W20171201-20:45:10.943(1)? (STDERR) http.request.abort();
W20171201-20:45:10.944(1)? (STDERR) ^
W20171201-20:45:10.944(1)? (STDERR)
W20171201-20:45:10.944(1)? (STDERR) TypeError: http.request.abort is not a function
W20171201-20:45:10.944(1)? (STDERR) at Request.stream.on.on (packages/ostrio:files/server.js:1769:24)
W20171201-20:45:10.944(1)? (STDERR) at emitNone (events.js:105:13)
W20171201-20:45:10.945(1)? (STDERR) at Request.emit (events.js:207:7)
W20171201-20:45:10.945(1)? (STDERR) at Request.abort (/home/hotello/Projects/sciumegu-web/node_modules/request/request.js:1177:8)
W20171201-20:45:10.945(1)? (STDERR) at ServerResponse.http.response.on (packages/ostrio:files/server.js:1744:18)
W20171201-20:45:10.945(1)? (STDERR) at emitNone (events.js:110:20)
W20171201-20:45:10.945(1)? (STDERR) at ServerResponse.emit (events.js:207:7)
W20171201-20:45:10.945(1)? (STDERR) at Socket.onServerResponseClose (_http_server.js:153:44)
W20171201-20:45:10.946(1)? (STDERR) at emitOne (events.js:120:20)
W20171201-20:45:10.946(1)? (STDERR) at Socket.emit (events.js:210:7)
After further investigation I noticed that the http.request object is an instance of IncomingMessage. Node's documentation does not report a .abort() method for IncomingMessage, however a .destroy() method exists.
Can someone reproduce this, or am I doing something wrong?
I'm on Meteor 1.6 and Meteor-Files 1.9.1.
Hello @hotello ,
Thank you a lot. Good catch :)
Although we can not reproduce described case, we can confirm a mistake and http.request has no .abort() method.
Additional questions:
@hotello thank you for submitting this issue. Fix is delivered in v1.9.2, please update.
Let me know if issue is fixed on your end.
Thank you very much @dr-dimitru, now it is fixed!
I was getting the error both in Firefox v57 and Chromium v63, on Lubuntu 16.04. It did happen on Heroku also.
@hotello thank you for additional info, unfortunately we haven't reproduced issue in the way you have described it.
But we are happy to hear it is solved on your end :)
Please, support this project by:
Most helpful comment
Thank you very much @dr-dimitru, now it is fixed!
I was getting the error both in Firefox v57 and Chromium v63, on Lubuntu 16.04. It did happen on Heroku also.