that sounds very reasonable

I pretty much never call write directly. I always let pipe do that for
me, and pipe cleans up after close, so that would work. and write will
never be called after 'close'.

I've been extremely enthusiastic about the Stream api for nearly a
year now, but have only just realized the purpose of 'close'.

I've written an informal spec up here, based on my understanding of
`Stream` and `pipe`

https://gist.github.com/2850882

I am just trying to document what a user stream must implement in
order to fully work with Steam#pipe, so this is a tad more general
than http://nodejs.org/api/stream.html

comments appreciated.

On Fri, Jun 1, 2012 at 7:57 PM, Axel Kittenberger <axk...@gmail.com> wrote:
> I'm not too much into the node specifics of streams, but I say.
>
> If its an expected end, call close.
> If its an unexpected end, call error then close,
> if someone calls write after close, throw an error. Since this should
> never happen in a correctly written application, if its okay it
> terminates if this is not catched.
>
> On Fri, Jun 1, 2012 at 7:54 AM, Dominic Tarr <dominic.t...@gmail.com> wrote:
>> what should a writable stream do if it's underlieing communication layer 
>> closes?
>> I see that .pipe listens on the end event of both source and dest streams,
>>
>> https://github.com/joyent/node/blob/master/lib/stream.js#L109
>>
>> what should the WritableStream do if write is called after 'close' is
>> emitted? emit an 'error'?
>>
>> how should someone writing to a stream know that the stream is closed?
>> listen on 'close'? or 'error'? or check stream.writable befor writing?
>>
>> what is the best way?
>>
>> cheers, Dominic
>>
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to nodejs@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to