-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
doc: clarify when writable.end callback is called #4810
Conversation
The current documentation for writable.end 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 nodejs#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. Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Sigh.. "may or may not" ...we should fix that |
Indeed. If there's agreement that it's worth fixing, I volunteer to send PRs for Reliably calling the callback from the |
I just realized the commit message and PR refer to |
LGTM Thanks for the contribution - any objection I merge this as is? |
Sounds good to me. No objection to merging it as-is. Thanks @benjamingr! |
LGTM |
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: #4810 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremy Whitlock <jcscoobyrs@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Thanks, landed in d955243 |
Tips for next time:
I did that for you (as well as the small text fix), so don't worry about it. You don't have to worry about it too much in the future too - just for reference. Thanks for the contribution! |
Minor nit @benjamingr. We're within the 10 minute window to update the message but the email for me should be If you don't want to fix it, not a big deal. |
A paste typo most likely, fixed real quick, thanks for noticing :) |
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: #4810 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Great. Thanks for fixing it up and merging it! (And the preceding reviews!) I'll omit the |
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: #4810 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
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: #4810 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
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: #4810 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
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: #4810 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
The current documentation for
writable.end
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 occurred).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.
Thanks for considering,
Kevin