-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add tests to check for the close event #5
base: master
Are you sure you want to change the base?
Conversation
847b69e
to
048ec46
Compare
Meanwhile, I've added the |
this one is kinda tricky because we are dealing with two streams and there is no guarantee that a stream will emit close. just waiting for the readable one to emit close seems a bit hackish to me, although if we waited for both the readable and the writable there is a decent chance that one of the streams will never emit close. thoughts? |
Agreed, specially if the readable and the writable are not logically connected (i.e two different sockets). If duplexify is wrapping a socket, we also don't want to loose the socket feeling and stop emitting that 'close'. 💡 Idea: What if we add a 'socket' mode through an options object, making the 'close' event a thing that respects to its readable and writable side, so that then, when boith readable and writable emit 'close', 'close' is emitted, and if only one side 'emits', it waits for a timeout to force close the other side, (flushing first if it is force closing the writable). |
I dont wanna add any timeout stuff to this module but to iterate your idea a bit i think a decent api would be. Per default, if both the readable and writable has emitted close we emit close (or if destroy is called like it is now). Add readableClose: false and writableClose: false options to disable waiting for close on either the readable or writable side. |
048ec46
to
a22bcdf
Compare
That sound good to me :) 👍 |
Hi @mafintosh!
I noticed today that the
close
event is not bubbled up from the underlying stream/socket to duplexify, in one of the sides, after adestroy
is called. This seems truth for both 'destroying on the dialer' and 'destroy on the listener'. I made a couple of tests to show it.It was kind of my expectation that the
close
event from the socket would bubble up in both sides, am I missing here anything or is this really a bug?Thank you :)