mike-marcacci / fs-capacitor

Filesystem-bufferred, passthrough stream that buffers indefinitely rather than propagate backpressure from downstream consumers.
MIT License
36 stars 8 forks source link

No write event emiter #9

Closed nikonhub closed 5 years ago

nikonhub commented 5 years ago

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.

image

Do you think it should be added manually. Because I can not find a write event in nodejs doc.

image

mike-marcacci commented 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!

nikonhub commented 5 years ago

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.

mike-marcacci commented 5 years ago

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.