-
-
Notifications
You must be signed in to change notification settings - Fork 231
Discuss: Gulp looking to move off of Node Streams #181
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
Comments
Well... can we blame them? ;-) ... I'm not too familiar with the issues they've been having, is there a list or summary somewhere that outlines the main issues? Perhaps @phated or one of the others could weigh in here? |
Some things we have been dealing with are: error management, having a stream that is sometimes-writeable/sometimes-transform depending on how it is being used, unpipe management. Chris is well-versed in the issues because I need his help untangling the problems much of the time. |
Yeah, I've seen similar problems elsewhere. Definitely should get this fixed once and for all... streams lead to... sadness... |
Node.js Steams are the worst except for all other streaming implementations :( |
The big problems I see with the state of streams as it stands are that:
This list is non-exhaustive, but I think we can make definite progress if we:
@mikeal: (obligatory: WHATWG streams have some neat solutions to the above — for example, while the |
From this comment:
I think Promises (and to a lesser degree, In that respect, |
Regardless of Being a user of build systems since years, but having dropped any around 01/2015, I have quite some experience with all of them. I chose My point being is, that is largely a problem of implementation. I tried to hack on |
I guess part of this is we could bring back up the idea of some sort of error forwarding method or forwarding of unhandled error events |
A good stream API should be:
Our experience with streamsAt Sage, we are using streams extensively in a large node.js project (~200 klocs not including dependencies). We are not using the native node.js API, though, but the ez-streams API instead. The ez-streams library/API is based on the following principles:
(*) high level API does not try to shoehorn everything into streams and pipes. Instead, it singles out operations like Core API
That's all you need to know to implement streams: reader = 2 methods, writer = 1 method. Notes:
High-level APIThe decorator transforms an implementation of the simple core API into a stream with a rich API. This API is a natural extension of the JS array API. A typical stream chain looks like: reader.transform(parser).filter(filter).map(mapper).transform(formatter).pipe(cb, writer); The high level API provides two types of methods:
(*) or a writer into another writer, with a simple API trick (the Evaluation is always lazy (nothing happens until a reducer starts to pull from a chain). Error handling is simple, robust and systematic: all reducers take a continuation callback parameter. Any uncaught error occurring in a chain ends up in the reducer's callback at the end of the chain. The reducer callback also allows you to reliably handle the end of a chain, and for example, ensure that writers have been flushed before continuing. The monadic methods ( A reader chain can be forked. In this case all emerging chains must be terminated by a reducer. The branching methods ( Interop with node.js streams.ez-streams sits side by side with node.js streams and provides a simple API to transform back and forth:
Same for writers. There is also a method ( This is safe. Node streams are not hacked. MoraleA better API is possible. Hacking around the current stream API/implementation won't solve the problem. It will just make things more complex. What we need is a fresh API which coexists with the current API and can be transformed back and forth. The new API should be continuation-based and high-level/monadic rather than event-driven and low-level. ez-streams can be a source of inspiration. I'm not expecting it to be taken verbatim (it could be easily adapted for promises) but I think that the design principles should be taken into consideration in a future iteration on a streaming API for node. I know that I'm probably being loud with this as I've already tried to influence the stream API design several times, without much success. I'm posting again because the problems are obviously still around (otherwise this thread would not exist) while, on the other hand, we have been very successful with the ez-streams approach at Sage. Maybe the time has come...
|
@eljefedelrodeodeljefe Gulp has been downloaded around 1.5 million times in the last month — it is very much an important consumer of streams. In the course of building an ecosystem around Gulp they've uncovered a lot of edge cases in Node's streams implementation and have always been forthcoming about getting those bugs fixed in core where possible. We should trust that the pain points they've highlighted are valid, not accuse them of bad implementation (remember: they're watching this thread, and were kind enough to bring this switch to our attention.) @bjouhier While ez-stream has nice properties, suggesting an entirely different stream system is a non-starter. We need to figure out where we're at and take concrete steps to improve streams within the existing Node API. @calvinmetcalf I think that would be an excellent idea. IIRC, I think @mcollina also proposed standardizing |
For the record, I created a ticket about this. |
I agree on @chrisdickinson in #181 (comment). I think we should list the issues and kick off a stream-wg discussion around those. What am I seeing are:
The situation is currently a mess, but a mess that is working extremely well in production. The goal should be to reduce the friction and lower the steep learning curve of streams. Anything else? |
@mcollina I think you're spot on. My additions would be:
I think particularly in terms of documentation improvements could be made. @chrisdickinson has done great work in streams notes and streams charts; I think he was onto something there. |
I agree with @mcollina @yoshuawuyts. Having a |
👍 for having a meeting. But I think we should set an aged to discuss all points first. IMHO: changing pipe behavior, destroy, _flush and docs are all important topics that we need to address. |
I am not much aware of the Node.js stream semantics. So ignore if this is a pretty noob question. Does our implementation adhere to a specification? Promises had similar problems and when A+ came in the dust kinda settled down a bit. Similarly streams also have multiple specifications. The one that I know of is reactive streams. |
@thefourtheye there are really no promise A+ style thing and to complicate matters when people talk about 'streams' they talk about 2 different things
reactive streams often really mean the first one and node streams are the second kind. |
Isn't the other way around? |
Just jumping in as someone who is new to but deep diving this stuff. I'm happy to lend a hand improving the documentation story around streams as improvements come. It's not a trivial subject for new comers and the docs are lacking around them, exacerbated by what @mcolina says about userlad dependencies for potentially core features. |
@thefourtheye why don't you open up a new issue to discuss the differences between streams, we probably don't want to add to much extra noise to this one. |
@chrisdickinson my point was here, that we just shouldn't get too nervous that a potentially stalling, while merited repo has some problems. However I think they and others have issues @mcollina described as
|
I'm 👍 on a meeting, discussing next steps in terms of WG work would be super useful. However, I'd like us to avoid deciding on a technical direction in-meeting until we have a concrete proposal in some form or another. Maybe figuring out what form that takes can be part of the agenda? |
I'm down with that On Sat, Jan 30, 2016 at 2:30 AM Chris Dickinson notifications@github.com
|
I think it may be useful to not solve everything here. Solve flowing data in a pipeable way (with optional backpressure); try to avoid catering to very many edge-cases. |
Just adding a little point: mcollina/split2#8 (comment) |
@stevemao whatwg streams !== node streams; node streams haven't been specced by a committee - they have an implementation and documentation to support it managed by the streams working group |
@yoshuawuyts @stevemao just wanna reiterate that the issue linked isn't really streams error handling related. more generic error handling. |
@yoshuawuyts I realised it so I removed my comment. |
The reason I linked that is because it is relevant on how we need to fix streams. We should really kick off a meeting. How about the week between 22/02 and 26/02? |
Fundamentally, since it is user-facing, documentation is specification. For node streams, it seems sorely wanting for clarity. I am a newbie; however, the way Stream.pipe is used suggest streams are FIFO queues. Yet the documentation has notions of writable, readable, and duplex Streams, as though a stream is either one or the other. Clearly, pipe makes it all of them. Perhaps the first steps to cleaning this up should be an elaboration of the unit tests to further crystallize known functionality and patterns of use as a basis for user land documentation. I have become increasingly aware that things are hard only because the documentation is bad. The documentation is bad when the implementation is bad. The implementation is bad when the design is bad. The design is bad when the specification is bad. The specification is usually bad for most of the pieces in versions 0 and.1, reducing onwards, not surprisingly. It would seem it's time for streams. |
@matteocollina the week of Feb 22 seems good we should make another issue with an agenda and precise timing @gdennie streams may be readable, writable, or both (duplex) , some streams that are both readable and writable do act as fifo queues and we call those transform streams. |
@calvinmetcalf It seems writable streams are also readable streams since all streams implement pipe. |
Hi @gdennie, I personally have a lot of problems working with stream. So we need to improve it for sure.
I don't think this tells too much what we should do to improve it but it sounds like a complaint to me. If you could help and give more constructive suggestions that would be great :) Thanks. |
@gdennie writable streams do NOT have a pipe method and are not readable, if you read documentation that suggests or implies the other case it's wrong and we can fix it if you can point us to it. |
One good thing came out of this https://www.npmjs.com/package/cloneable-readable. |
It might be worthwhile to look into the conversation going on here — Gulp is a pretty heavy user of Node streams, and it looks like we're not serving them well at present. In particular, I'd like to pose the following questions:
/cc @nodejs/streams
The text was updated successfully, but these errors were encountered: