Skip to content

Commit 2be0eb6

Browse files
authored
Merge pull request #1167 from kalenikalexander/handle_backpressure
handle backpressure when loading data from file
2 parents a972bb4 + dbaed31 commit 2be0eb6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/connection.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,15 @@ class Connection extends EventEmitter {
227227
}
228228

229229
write(buffer) {
230-
this.stream.write(buffer, err => {
230+
const result = this.stream.write(buffer, err => {
231231
if (err) {
232232
this._handleNetworkError(err);
233233
}
234234
});
235+
236+
if (!result) {
237+
this.stream.emit('pause');
238+
}
235239
}
236240

237241
// http://dev.mysql.com/doc/internals/en/sequence-id.html

0 commit comments

Comments
 (0)