Closed nikonhub closed 5 years ago
Thanks so much for the detailed investigation! I am slammed today but I’ll look into this tomorrow. Keep posting if you learn anything more!
No hurry :). I don't think I can dig more than this solution. It seems we should manually call emit on write event when a _write occurs.
I ran your tests and all passes. In my case it fix the problem but I can not foresee all cases when it could misbehave.
Thanks so much for the investigation @Nikosmonaut! It looks like I inadvertently removed the event in this commit and didn't have tests to protect against this kind of timing bug.
The correct behavior has been restored (along with some new tests) and is published as a patch.
When unread === 0 we add listeners on write and finish events. But it seems the write event is never emited.
So the problem I have is when my writeStream has no more to read because the upload is too slow it waits to the finish event (full upload) before restart writing.
Do you think it should be added manually. Because I can not find a write event in nodejs doc.