code: func (nc *Conn) checkDrained(sub *Subscription) {
  	if nc == nil || sub == nil {
  		return
  	}
  
  	// This allows us to know that whatever we have in the client pending
  	// is correct and the server will not send additional information.
  	nc.Flush()
  
  	// Once we are here we just wait for Pending to reach 0 or
  	// any other state to exit this go routine.
  	for {
  		// check connection is still valid.
  		if nc.IsClosed() {
  			return
  		}
  
  		// Check subscription state
  		sub.mu.Lock()
  		conn := sub.conn
  		closed := sub.closed
  		pMsgs := sub.pMsgs
  		sub.mu.Unlock()
  
  		if conn == nil || closed || pMsgs == 0 {
  			nc.mu.Lock()
  			nc.removeSub(sub)
  			nc.mu.Unlock()
  			return
  		}
  
  		time.Sleep(100 * time.Millisecond)
  	}
  }
docs: // checkDrained will watch for a subscription to be fully drained
  // and then remove it.