diff --git a/lib/connection.js b/lib/connection.js index de5381864b..e43410a13e 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -223,11 +223,15 @@ class Connection extends EventEmitter { } write(buffer) { - this.stream.write(buffer, err => { + const result = this.stream.write(buffer, err => { if (err) { this._handleNetworkError(err); } }); + + if (!result) { + this.stream.emit('pause'); + } } // http://dev.mysql.com/doc/internals/en/sequence-id.html