OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
fix(worker): await GroupMQ worker.run() to prevent silent shard-stuck (#413)
ayushjhanwar-pngfad1f3ffe38e
diff --git a/apps/worker/src/boot-workers.ts b/apps/worker/src/boot-workers.tsindex 3ca6b7ef3..d3451bb50 100644--- a/apps/worker/src/boot-workers.ts+++ b/apps/worker/src/boot-workers.ts@@ -167,7 +167,17 @@ export function bootWorkers() {worker.on('completed', markEventsActivity);worker.on('drained', markEventsActivity);- worker.run();+ // Fail loud on startup — silent stuck shard otherwise.+ // Runtime errors are handled by the shared workers.forEach listener below.+ worker.run().catch((err) => {+ logger.error(+ { shard: index, queueName, err },+ 'Worker startup failed — exiting',+ );+ // setTimeout+unref to let the logger flush before exit (matches the+ // pattern used by uncaughtException/unhandledRejection handlers below).+ setTimeout(() => process.exit(1), 1000).unref();+ });workers.push(worker);logger.info({ concurrency }, `Started worker for ${queueName}`);}