MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / waitForQueueToEmpty

Function waitForQueueToEmpty

apps/worker/src/boot-workers.ts:410–434  ·  view source on GitHub ↗
(queue: Queue, timeout = 60_000)

Source from the content-addressed store, hash-verified

408}
409
410export async function waitForQueueToEmpty(queue: Queue, timeout = 60_000) {
411 const startTime = performance.now();
412
413 while (true) {
414 const activeCount = await queue.getActiveCount();
415
416 if (activeCount === 0) {
417 break;
418 }
419
420 if (performance.now() - startTime > timeout) {
421 logger.warn(
422 { queue: queue.name, remainingCount: activeCount },
423 'Timeout reached while waiting for queue to empty'
424 );
425 break;
426 }
427
428 logger.info(
429 { queue: queue.name, count: activeCount },
430 'Waiting for queue to finish'
431 );
432 await sleep(500);
433 }
434}

Callers 1

exitHandlerFunction · 0.85

Calls 3

infoMethod · 0.80
sleepFunction · 0.50
warnMethod · 0.45

Tested by

no test coverage detected