Closed blackmad closed 1 year ago
actually ... I think this doesn't work because the finish event still flows through to other streams too early
working on a reduced case repro for this, I spent a while in the avsc code trying to fix it and couldn't quite get there. it's something about overriding the _final function in the Duplex stream and not calling the passed callback until we know we're done, but I was struggling to know if there was another block left.
Hi! ๐
Firstly, thanks for your work on this project! ๐
Today I used patch-package to patch
avsc@5.7.7
for the project I'm working on.I noticed that the "finish" event was being emitted on my stream before I had actually finished reading all the rows. I'm not sure if this is a consequence of using snappy with using an async callback to do its work. I observed this behavior empirically in a test, in production code, and via the use of logs. I think the issue is that the code passes through the finish event when it reads the last bytes, but not when it finishes decoding them.
I'm not sure if this is the right solution - I couldn't figure out how to make a Duplex stream swallow the "finish" event, so I added another "done" event that appears to more correctly finish.
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.