Skip to content

Commit dbaed31

Browse files
kalenikalexanderrnavarych
authored andcommitted
handle backpressure when loading data from file
1 parent daecdda commit dbaed31

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
@@ -223,11 +223,15 @@ class Connection extends EventEmitter {
223223
}
224224

225225
write(buffer) {
226-
this.stream.write(buffer, err => {
226+
const result = this.stream.write(buffer, err => {
227227
if (err) {
228228
this._handleNetworkError(err);
229229
}
230230
});
231+
232+
if (!result) {
233+
this.stream.emit('pause');
234+
}
231235
}
232236

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

0 commit comments

Comments
 (0)