doc: clarify when writable.write callback is called
authorKevin Locke <kevin@kevinlocke.name>
Fri, 22 Jan 2016 00:07:50 +0000 (16:07 -0800)
committerMyles Borins <mborins@us.ibm.com>
Mon, 21 Mar 2016 19:57:53 +0000 (12:57 -0700)
commit0830bb4950a7624efa7c4c370d6e4d687f490871
tree8fe9b3173b2a9b6dca1658d98a856dd4e9b03c9f
parent068b0cbd12f225d946670de1c92c39496579bd7c
doc: clarify when writable.write callback is called

The current documentation for writable.write only specifies that the
callback is called "once the data has been fully handled".  It is
ambiguous whether this means "successfully handled" and, if so,
whether the callback is called if the data can not be successfully
handled (i.e. an error occurs).

The ambiguity is not only in the documentation.  The stream class
implementations differ on this point.  stream.Writable invokes the
callback with any errors that occur during parameter checking or
during calls to _write.  However, not all classes return all errors
to _write. zlib.Zlib does pass argument and state errors to the
_write (_transform) callback, but does not pass data errors.
http.OutgoingMessage passes argument type errors and some other types
of errors, but not all.

This inconsistency is behind issue #1746 and, I suspect, other issues
in client code which passes a callback to write.

This commit takes no position on whether the callback error behavior
should changed, but simply attempts to document the current behavior
in a way that is open to changes so that users are not caught by
surprise.

PR-URL: https://github.com/nodejs/node/pull/4810
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
doc/api/stream.markdown