code: function drainQueue(jobInfo) {
          function drainNext() {
              return drainQueue;
          }
  
          var queue = jobInfo.job._queue;
  
          if (queue.length === 0 && eventQueue.length > 0) {
              queue = jobInfo.job._queue = copyAndClearQueue();
          }
  
          jobInfo.setPromise(drainOneEvent(queue).then(drainNext, drainNext));
      }
docs: Drains the event queue via the scheduler