From 6eb98d866b2778ec7e94b3d05018aaee037954e8 Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Tue, 26 May 2026 07:38:07 -0400 Subject: [PATCH] fix(youtube-import): export proxyQueue singleton for clean SIGTERM shutdown (issue #94 bug 7) --- services/worker/src/workers/youtube-import.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/worker/src/workers/youtube-import.js b/services/worker/src/workers/youtube-import.js index 12472ca..f2765a5 100644 --- a/services/worker/src/workers/youtube-import.js +++ b/services/worker/src/workers/youtube-import.js @@ -19,8 +19,11 @@ const parseRedisUrl = (url) => { return { host: parsed.hostname, port: parseInt(parsed.port, 10) }; }; -// Hand off to the existing proxy queue once the original is in S3. -const proxyQueue = new Queue('proxy', { +// BUG FIX #7: Keep proxyQueue as a module-level singleton so it is only +// opened once and can be closed on SIGTERM (via the exported closer). +// Previously the worker created a new Queue on every job invocation; each +// BullMQ Queue holds an open Redis connection that prevented clean shutdown. +export const proxyQueue = new Queue('proxy', { connection: parseRedisUrl(process.env.REDIS_URL || 'redis://queue:6379'), });