async function awaitQueueDrain() {
  console.log(`Awaiting processing queue to drain. Messages in queue: ${processQueue}`);

  return new Promise((resolve) => {
    const intervalId = setInterval(() => {
      if (processQueue > 0) {
        console.log(`Messages in queue: ${processQueue}`);
        return;
      }
      console.log('All messages processed!');
      clearInterval(intervalId);
      resolve();
    }, 1000);
  });
}
// Wait for all messages to be processed
Wait for all messages to be processed
Wait for all messages to be processed
async function awaitQueueDrain() {
  console.log(`Awaiting processing queue to drain. Messages in queue: ${processQueue}`);
  return new Promise((resolve) => {
    const intervalId = setInterval(() => {
      if (processQueue > 0) {
        console.log(`Messages in queue: ${processQueue}`);
        return;
      }
      console.log('All messages processed!');
      clearInterval(intervalId);
      resolve();
    }, 1000);
  });
}
async function awaitQueueDrain ( ) { console . log ( ` ${ processQueue } ` ) ; return new Promise ( ( resolve ) => { const intervalId = setInterval ( ( ) => { if ( processQueue > 0 ) { console . log ( ` ${ processQueue } ` ) ; return ; } console . log ( 'All messages processed!' ) ; clearInterval ( intervalId ) ; resolve ( ) ; } , 1000 ) ; } ) ; }
Wait for all messages to be processed
Wait for all messages to be processed