-
Notifications
You must be signed in to change notification settings - Fork 147
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
[#691] Propagate destroy from consumers to sources #692
base: 2.x
Are you sure you want to change the base?
Conversation
…ped node Readable stream
My changes have surfaced an issue which also exists in current 2.x whereby a stream tries to write after it's been ended. e.g. const s = _(new Promise((r) => setTimeout(() => r('Hello'), 1000)));
s.each((a) => {
console.log(a);
})
f1.destroy();
Not sure if there is a way to cancel pending requests on end, or if write would have to be more lenient; perhaps noop + warn instead of throw in this scenario? Thinking about it...it seems like a similar problem whereby the destroy isn't propagated to the |
The
I agree with you about With Of the top of my head, here are the other work that needs to be done
All of this can be accomplished with the proper motivation and time. Unfortunately I no longer use Highland in my day-to-day work1, so I have less motivation and far less time to make these kinds of sweeping changes to the library. If you want to do this yourself, I'm happy to accept PRs against the 1 This is not meant to be a comment on the suitability of the library for any particular purpose, merely a comment on the realities of my current job. |
@vqvu thanks for the info -- I'd love to work on this but it's unlikely I'll be able to invest enough time right now unfortunately. It's a shame 3.0 hasn't made it out the door but I totally appreciate your position; it looks like you've put a lot of work in already to get it this far! I do think highland is of huge value to the Node ecosystem and really enables Node streams to reach their full potential. I wonder whether the |
@vqvu I know you've indicated that making this work is difficult but I think it's a really important feature for usage with Node streams, so thought I'd give it a stab to try and understand the issue better.
There's sure to be holes in my implementation as I'm v. new to highland so don't have a complete understanding of the library and I've largely been considering my specific use-case of piping to a
Node.ServerResponse
.Currently this is what I've done:
Stream
is destroyed, also destroy the underlying nodeReadable
stream.This solves this problem:
This solves this problem:
I think the above is where the difficulty you mentioned comes in due to
fork
&observe
. I've currently taken the stance thatobserve
never propagates destroy andfork
always propagates destroy, although I thinkfork
should probably actually only propagate destroy if all siblings have ended too, i.e. there are no more active consumers on the source.Additionally, if this could be made to work -- I imagine it'd make sense for it to be opt in for cases where you do not want to destroy the readable, e.g.
Anyway, I understand if you're not interested as it sounds like you've been down this path before but happy to help out if you think this can be made to work.