caolan / async

Async utilities for node and the browser
http://caolan.github.io/async/
MIT License
28.18k stars 2.41k forks source link

queue.drain is not a function #1746

Closed ashmortar closed 3 years ago

ashmortar commented 3 years ago

What version of async are you using? 3.2.0 Which environment did the issue occur in (Node/browser/Babel/Typescript version) Electron 10.1.4 => Node 12.16.3 => typescript 3.9.7 What did you do? Please include a minimal reproducible case illustrating issue. I have tried both:

class SomeClass {
 constructor() { 
   this.doingThingsQueue = Async.queue(this.handleProcessQueueItem, 2);
   this.doingThingsQueue.drain(() => console.log('all done' ));  
   }

   handleProcessQueueItem(item, callback) {
     console.log(item);
     callback();
   }

   processThings(items) {
     this.doingThingsQueue.push(items);
     return { success: true }
   }
}

and:

class SomeClass {
 constructor() { 
   this.doingThingsQueue = Async.queue(this.handleProcessQueueItem, 2);
   }

   handleProcessQueueItem(item, callback) {
     console.log(item);
     callback();
   }

   processThings(items) {
     this.doingThingsQueue.push(items);
     this.doingThingsQueue.drain(() => console.log('all done' ));  
     return { success: true }
   }
}

in addition to trying to assign the function this.doingthingQueue.drain = () => console.log('all done');

but all situations result in each item processing but then getting the error:

What did you expect to happen? all done to be logged in the console when the queue is empty.

What was the actual result?

TypeError: this.doingThingsQueue.drain is not a function

aearly commented 3 years ago

Closing old issues, hope you figured it out.