Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

docs: missing prefinish writable stream event #8767

Closed
mscdex opened this issue Nov 22, 2014 · 8 comments
Closed

docs: missing prefinish writable stream event #8767

mscdex opened this issue Nov 22, 2014 · 8 comments

Comments

@mscdex
Copy link

mscdex commented Nov 22, 2014

This bit me tonight. I had a script that worked fine in node 0.10.33 but 0.11.14 was calling finish on next tick or later, causing unexpected behavior. After diving into the code I found that there is now also a prefinish event that I now listen on for node 0.11+.

It seems like if backwards compatibility can't be kept here, that prefinish should at least be publicly documented along with information comparing it to finish and how it all deviates from node 0.10 behavior.

@misterdjules
Copy link

Are you able to share this code with us, or at least the relevant part?

@mscdex
Copy link
Author

mscdex commented Dec 2, 2014

Sure, it's here.

Without the prefinish handler, I get stream.push() after EOF on just about every node v0.11.x release.

To reproduce, comment out the .on('prefinish', onFinish'); line and then run node test/test-client-server.js with both node v0.10.33 and v0.11.14. It works just fine on v0.10, but crashes with that error on v0.11. Uncomment the line and everything works again on both node versions.

I don't have time at the moment to create a minimal test case for this, but it seems the change was introduced in c38ce9bc0a.

@misterdjules
Copy link

I couldn't run node test/test-client-server.js. It seems that this test is only present in ssh2's branch named "rewrite". However, running npm install in this branch results in an error because it can't find the npm module ssh2-streams. What can I do to run this test?

Nonetheless, I investigated why the finish event could not be emitted in some cases, and I came up with a change and a test. Could you please let me know if that's related to your issue?

Thank you!

@mscdex
Copy link
Author

mscdex commented Dec 10, 2014

It's not that it isn't emitting finish, but it's emitting it later than it does in node v0.10. It seems that prefinish has taken the place (time-wise) of finish from node v0.10 and now finish in v0.11 has some new meaning?

Sorry about the lack of instructions. You should just need to checkout the rewrite branch and then do npm install https://github.com/mscdex/ssh2-streams/tarball/master in the rewrite's root directory.

@misterdjules
Copy link

Sorry, I had read your second comment only and lost the context. I'll take another look later, thank you for the instructions on how to install ssh2-streams.

@jasnell jasnell added the doc label Jun 4, 2015
@jasnell
Copy link
Member

jasnell commented Jun 24, 2015

@mscdex ... still something you'd like to see? have time to do a PR?

@mscdex
Copy link
Author

mscdex commented Jun 24, 2015

@jasnell Yes, it is still something I'd like to see. However I don't know the reasons for the change in behavior and all that, so I'm probably not the best one to write documentation for it.

@jasnell
Copy link
Member

jasnell commented Jun 25, 2015

@chrisdickinson @trevnorris ... are either of you able to clarify the change that was made here?

@Trott Trott closed this as completed Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants