doc: add comments about Readable unpipe on Writable error event in stream.md#18080
doc: add comments about Readable unpipe on Writable error event in stream.md#18080GeorgeSapkin wants to merge 1 commit intonodejs:masterfrom GeorgeSapkin:stream-unpipe-doc
Conversation
|
Hi, thanks for the PR! You edited the section for stream implementors that tells them how to report errors; I think this would be better kept in the section about |
|
Do you think it should be in Readable.pipe() section? It seems to me it affects the Writable stream implementers more since right now it is not clear what happens when Writable emits errors. Maybe it should be in both or there should some kind of a reference between the sections? I've improved the wording to make it clearer which stream emits an error. |
doc/api/stream.md
Outdated
There was a problem hiding this comment.
Nit: Consider removing *Note*: and letting the sentence stand on its own?
There was a problem hiding this comment.
This seems like something that requires special attention when implementing error handling in Writable streams and STYLE_GUIDE.md recommends to mark such things with a *Note*:.
There was a problem hiding this comment.
That should probably be updated as well. We try to minimize those because they became to frequent and therefore lost there meaning.
There was a problem hiding this comment.
I've removed the *Note*.
doc/api/stream.md
Outdated
There was a problem hiding this comment.
Nit: add the before Readable stream.
|
I agree with @addaleax that it should be moved to the pipe part. |
|
@BridgeAR why would this be in the Writable |
|
@GeorgeSapkin yes Something like e.g. might fit? @mcollina PTAL |
|
I think we should really add the sentence in 2-3 places. It's one of the most forgotten (and bad) features of streams. I would also note that calling |
|
Can you add a sentence about the fact |
|
Ping @GeorgeSapkin |
|
@mcollina I'm not sure I understand where the note about streams not being closed on |
|
@GeorgeSapkin the main reason is that a stream is typically holding on to some native resources. A file descriptor, or some other native data. If an error happen and the destination stream is unpiped, the underlining native resource is not freed, and will trigger a memory (or file descriptor) leak. |
|
I would say we can land this as is (it already improves the current situation) and we have a follow up PR that addresses your comment @mcollina ? |
|
👍 |
|
Landed in 1d19fd3 |
PR-URL: #18080 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#18080 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#18080 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#18080 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Documenting Readable unpiping behavior according to: https://github.com/nodejs/node/blob/v8.x/lib/_stream_readable.js#L656-L664
Checklist
Affected core subsystem(s)
doc