@@ -186,6 +186,7 @@ function WritableState(options, stream, isDuplex) {
186
186
}
187
187
188
188
ObjectDefineProperties ( WritableState . prototype , {
189
+ // Backwards compat.
189
190
writing : {
190
191
get ( ) {
191
192
return ! ! this . writecb ;
@@ -323,11 +324,7 @@ Writable.prototype.uncork = function() {
323
324
if ( state . corked ) {
324
325
state . corked -- ;
325
326
326
- if ( ! state . writecb &&
327
- ! state . corked &&
328
- ! state . bufferProcessing &&
329
- state . bufferedRequest )
330
- clearBuffer ( this , state ) ;
327
+ clearBuffer ( this , state ) ;
331
328
}
332
329
} ;
333
330
@@ -432,13 +429,7 @@ function onwrite(stream, er) {
432
429
onwriteError ( stream , state , er , cb ) ;
433
430
}
434
431
} else {
435
- // Check if we're actually ready to finish, but don't emit yet
436
- const finished = needFinish ( state ) || stream . destroyed ;
437
-
438
- if ( ! finished &&
439
- ! state . corked &&
440
- ! state . bufferProcessing &&
441
- state . bufferedRequest ) {
432
+ if ( state . bufferedRequest ) {
442
433
clearBuffer ( stream , state ) ;
443
434
}
444
435
@@ -503,6 +494,13 @@ function errorBuffer(state, err) {
503
494
504
495
// If there's something in the buffer waiting, then process it
505
496
function clearBuffer ( stream , state ) {
497
+ if ( state . writecb ||
498
+ state . corked ||
499
+ state . bufferProcessing ||
500
+ ! state . bufferedRequest ) {
501
+ return ;
502
+ }
503
+
506
504
state . bufferProcessing = true ;
507
505
let entry = state . bufferedRequest ;
508
506
0 commit comments