code: public void removeAndFail(Throwable cause) {
          assert ctx.executor().inEventLoop();
          if (cause == null) {
              throw new NullPointerException("cause");
          }
          PendingWrite write = head;
  
          if (write == null) {
              return;
          }
          ReferenceCountUtil.safeRelease(write.msg);
          ChannelPromise promise = write.promise;
          safeFail(promise, cause);
          recycle(write, true);
      }
docs: Remove a pending write operation and fail it with the given {@link Throwable}. The message will be released via
  {@link ReferenceCountUtil#safeRelease(Object)}.