Last active
August 29, 2015 14:26
-
-
Save silverwind/54b3829142f93d1127bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var streamifier = require('streamifier'); | |
var Busboy = require('busboy'); | |
var FormData = require('form-data'); | |
var PORT = 6666; | |
var data = new Buffer(100 * 1024 * 1024); | |
http.createServer(function(req, res) { | |
var busboy = new Busboy({headers: req.headers}); | |
busboy.on('file', function() { | |
console.log('uploaded:', mb(data.length),' - memory used:', mb(process.memoryUsage().rss)); | |
setTimeout(upload, 1000); | |
}); | |
req.pipe(busboy); | |
}).listen(PORT, '127.0.0.1', upload); | |
function upload() { | |
var form = new FormData(); | |
form.append('file', streamifier.createReadStream(data), { | |
filename: 'upload', | |
contentType: 'application/octet-stream', | |
knownLength: data.length | |
}); | |
form.submit('http://127.0.0.1:' + PORT); | |
} | |
function mb(val) { | |
return Math.round(val / (1024 * 1024)) + " MB"; | |
} |
@skomsi: Good find, it seems to solve the leak. It's kind of obvious now that the data is lost in that unconsumed stream, thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should fix it, or?