code: public void removeAndFailAll(Throwable cause) {
          assert ctx.executor().inEventLoop();
          if (cause == null) {
              throw new NullPointerException("cause");
          }
          // It is possible for some of the failed promises to trigger more writes. The new writes
          // will "revive" the queue, so we need to clean them up until the queue is empty.
          for (PendingWrite write = head; write != null; write = head) {
              head = tail = null;
              size = 0;
              bytes = 0;
              while (write != null) {
                  PendingWrite next = write.next;
                  ReferenceCountUtil.safeRelease(write.msg);
                  ChannelPromise promise = write.promise;
                  recycle(write, false);
                  safeFail(promise, cause);
                  write = next;
              }
          }
          assertEmpty();
      }
docs: Remove all pending write operation and fail them with the given {@link Throwable}. The message will be released
  via {@link ReferenceCountUtil#safeRelease(Object)}.