         return self.pendingWrites.hasMark()
     }
 
-    /// Fail all the outstanding writes.
+    /// Remove all pending writes and return a `EventLoopPromise` which will cascade notifications to all.
     ///
     /// - warning: See the warning for `didWrite`.
     ///
-    /// - returns: A closure that the caller _needs_ to run which will fulfill the promises.
-    public mutating func failAll(error: Error) -> (() -> Void) {
-        var promises: [EventLoopPromise<Void>] = []
-        promises.reserveCapacity(self.pendingWrites.count)
+    /// - returns: promise that needs to be failed, or `nil` if there were no pending writes.
+    public mutating func removeAll() -> EventLoopPromise<Void>? {
+        var promise0: EventLoopPromise<Void>?
+
         while !self.pendingWrites.isEmpty {
             if let p = self.fullyWrittenFirst() {
-                promises.append(p)
-            }
-        }
-        return { promises.forEach { $0.fail(error: error) } }
+                if let promise = promise0 {
+                    promise.futureResult.cascade(promise: p)
+                } else {
+                    promise0 = p
+                }
+            }
+        }
+        return promise0
     }
 
     /// Returns the best mechanism to write pending data at the current point in time.

                    unaccountedWrites -= headItemReadableBytes
                    /* we wrote at least the whole head item, so drop it and succeed the promise */
                    if let promise = self.fullyWrittenFirst() {
                        promises.append(promise)
                    }
                } else {
                    /* we could only write a part of the head item, so don't drop it but remember what we wrote */
                    self.partiallyWrittenFirst(bytes: unaccountedWrites)

                    // may try again depending on the writeSpinCount
                    return (fulfillPromises, .writtenPartially)
                }
            }
            assert(unaccountedWrites == 0, "after doing all the accounting for the byte written, \(unaccountedWrites) bytes of unaccounted writes remain.")
            return (fulfillPromises, .writtenCompletely)
        }
    }


    ///     - itemCount: The number of items we tried to write.
    ///     - result: The result of the write operation.
    private func didWrite(itemCount: Int, result: IOResult<Int>) -> OneWriteOperationResult {
        let (promise, result) = self.state.didWrite(itemCount: itemCount, result: result)

        if self.state.bytes < waterMark.low {
            channelWritabilityFlag.store(true)
        }

        promise?.succeed(result: ())
        return result
    }

