Pipe back pressure issue #273

Merged
merged 1 commit into from Jun 25, 2012

Projects

None yet

2 participants

@mafintosh
Contributor

Currently request doesn't return a boolean from write to indicate whether or not the write was flushed nor does it emit a drain event.

This can result in a large memory overhead when piping large files to request because of back pressure.
Consider:

fs.createReadStream('i_am_large.file').pipe(request.put('http://...');

If the above readstream reads faster than request can write we'll end up having most of the file in memory.
This patch fixes this issue by adding the drain event and returning the boolean from req.write.

@mikeal mikeal merged commit 9746bb4 into request:master Jun 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment