diff --git a/packages/bindings/lib/darwin.js b/packages/bindings/lib/darwin.js index 64aae0885..7bedeec2d 100644 --- a/packages/bindings/lib/darwin.js +++ b/packages/bindings/lib/darwin.js @@ -59,13 +59,16 @@ class DarwinBinding extends AbstractBinding { } write(buffer) { - this.writeOperation = super - .write(buffer) - .then(() => unixWrite.call(this, buffer)) - .then(() => { - this.writeOperation = null - }) - return this.writeOperation + if (buffer.length > 0) { + this.writeOperation = super + .write(buffer) + .then(() => unixWrite.call(this, buffer)) + .then(() => { + this.writeOperation = null + }) + return this.writeOperation + } + return Promise.resolve() } update(options) { diff --git a/packages/bindings/lib/linux.js b/packages/bindings/lib/linux.js index eae69807a..d0b11e0aa 100644 --- a/packages/bindings/lib/linux.js +++ b/packages/bindings/lib/linux.js @@ -59,13 +59,16 @@ class LinuxBinding extends AbstractBinding { } write(buffer) { - this.writeOperation = super - .write(buffer) - .then(() => unixWrite.call(this, buffer)) - .then(() => { - this.writeOperation = null - }) - return this.writeOperation + if (buffer.length > 0) { + this.writeOperation = super + .write(buffer) + .then(() => unixWrite.call(this, buffer)) + .then(() => { + this.writeOperation = null + }) + return this.writeOperation + } + return Promise.resolve() } update(options) { diff --git a/packages/bindings/lib/win32.js b/packages/bindings/lib/win32.js index b4750e363..f435b4d17 100644 --- a/packages/bindings/lib/win32.js +++ b/packages/bindings/lib/win32.js @@ -66,13 +66,16 @@ class WindowsBinding extends AbstractBinding { } write(buffer) { - this.writeOperation = super - .write(buffer) - .then(() => promisify(binding.write)(this.fd, buffer)) - .then(() => { - this.writeOperation = null - }) - return this.writeOperation + if (buffer.length > 0) { + this.writeOperation = super + .write(buffer) + .then(() => promisify(binding.write)(this.fd, buffer)) + .then(() => { + this.writeOperation = null + }) + return this.writeOperation + } + return Promise.resolve() } update(options) {