         head = pending.next
         if head == nil {
             tail = nil
-        }
+            flushCheckpoint = nil
+        }
+    }
+    
+    private func isFlushCheckpoint(_ pending: PendingWrite) -> Bool {
+        return pending === flushCheckpoint
+    }
+    
+    private func checkFlushCheckpoint(pending: PendingWrite) -> Bool {
+        if isFlushCheckpoint(pending) {
+            flushCheckpoint = nil
+            return true
+        }
+        return false
+    }
+    
+    private func isFlushPending() -> Bool {
+        return flushCheckpoint != nil
     }
     
     private func consumeOne(body: (UnsafePointer<UInt8>, Int) throws -> Int?) rethrows -> Bool? {
-        if let pending = head {
+        if let pending = head, isFlushPending() {
             if let written = try pending.buffer.withReadPointer(body: body) {
                 outstanding -= UInt64(written)
                 

                    // Directly update nodes as a promise may trigger a callback that will access the PendingWrites class.
                    updateNodes(pending: pending)
                    
                    // buffer was completely written
                    pending.promise.succeed(result: ())
                    if (isEmpty) {
                        // return nil to signal to the caller that there are no more buffers to consume
                        return nil
                    }

                    }
                }
                
                if (isEmpty || allFlushed) {
                    // return nil to signal to the caller that there are no more buffers to consume
                    return nil
                }
