Skip to content
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

feat: expose writeAll() and writeAllSync() #2298

merged 1 commit into from Jul 23, 2019


Copy link

commented May 6, 2019

Symmetric with readAll() and readAllSync(). Also used in xeval.
Also correct usage in writeFile()/writeFileSync().


This comment has been minimized.

Copy link

commented May 6, 2019

IMO write() should write everything, otherwise it is just too surprising. Doesn't it do that currently?
For really specialistic use cases writing "not all" could be appropriate, but that should be very obvious from the name of the function (e.g. writePartial).


This comment has been minimized.

Copy link
Contributor Author

commented May 7, 2019

@piscisaureus Not really. For example, write on a Conn have the following layers of implications (assuming Unix only):
ConnImpl.write ->
tokio_write::write ->
<Resource as AsyncWrite>::poll_write ->
tokio::net::TcpStream::poll_write ->
tokio::net::TcpStream::write ->
PollEvented<mio::net::TcpStream>::write ->
mio::net::TcpStream::write ->
sys::TcpStream::write ->
std::net::TcpStream::write ->
std::sys_common::net::TcpStream::write ->

As it eventually goes to send (2) and none of the above step does a write-all attempt, it is possible to write and return partially if something like signal interrupts happens when we have already written some data (from manpages on macOS, EINTR only triggers on no data written yet:)

[EINTR]            A signal interrupts the system call before any data is transmitted.
feat: expose writeAll() and writeAllSync()
Symmetric with `readAll()` and `readAllSync()`. Also used in `xeval`.
Also correct usage in `writeFile()`/`writeFileSync()`.

@ry ry force-pushed the kevinkassimo:buf/writeAll branch from 7faa90b to 26053ee Jul 23, 2019


This comment has been minimized.

Copy link

commented Jul 23, 2019

I've rebased on current master.


ry approved these changes Jul 23, 2019

Copy link

left a comment

LGTM - sorry for the delay

@ry ry merged commit e49d1e1 into denoland:master Jul 23, 2019

3 checks passed

Travis CI - Pull Request Build Passed
continuous-integration/appveyor/pr AppVeyor build succeeded
license/cla Contributor License Agreement is signed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.