code: void writeFinished(Object error) {
          checkThread();
          writingBuffer = null;
          Promise wp = this.writePromise;
          writePromise = null;
          if ( ! wp.isSettled() ) {
              if ( error != null )
                  wp.reject(error);
              else
                  wp.resolve();
          }
      }
docs: error = null => ok