Closed grantila closed 9 years ago
I realize this is similar to #6, although I think it is wise to not combine flow control with user-driven actions such as pause/resume. You can easily get "race conditions" between a user pressing pause/resume buttons with the flow control, if implemented as #6.
This pull request is separated from pause/resume, and leaves this entirely up to the user.
In #6, when using large chunks, a user could aggressively press a "resume" button (given such a button exists in the application) to force more and more data to be sent over the stream even though it would violate the back pressure.
Sorry, I ended up rewriting this module. A new version is out now as 1.0.0 with streams2 support
Currently filereader-stream keeps pushing data unless you explicitly pause it. Try to use it to upload a file n times larger the amount of RAM you have, and you'll practically kill your browser.
It should not send more until it has received the flush callback.
While implementing this, I saw that it also tends to write after end, a newer concat-stream exposes this in the unit test. It's not a major issue, as we write an empty buffer. The cause is that we get an empty event from the FileReader for some reason after the file is completely read.
This pull request fixes both of the above.