@zintrust/queue-redis 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,7 @@ export const BullMQRedisQueue = (() => {
29
29
  let sharedConnection = null;
30
30
  let lockProviderCache = null;
31
31
  const PULL_WORKER_TOKEN = 'pull-worker';
32
+ const SHARED_CONNECTION_SHUTDOWN_TIMEOUT_MS = 100;
32
33
  const isRedisProxyEnabled = () => {
33
34
  return Env.USE_REDIS_PROXY === true || Env.get('REDIS_PROXY_URL', '').trim() !== '';
34
35
  };
@@ -140,6 +141,40 @@ export const BullMQRedisQueue = (() => {
140
141
  client.once('end', onEnd);
141
142
  });
142
143
  };
144
+ const closeSharedConnection = async (client) => {
145
+ let timeoutId;
146
+ try {
147
+ await Promise.race([
148
+ client.quit(),
149
+ new Promise((_, reject) => {
150
+ timeoutId = globalThis.setTimeout(() => {
151
+ reject(ErrorFactory.createGeneralError('BullMQ shared Redis shutdown timed out', {
152
+ timeoutMs: SHARED_CONNECTION_SHUTDOWN_TIMEOUT_MS,
153
+ }));
154
+ }, SHARED_CONNECTION_SHUTDOWN_TIMEOUT_MS);
155
+ timeoutId.unref?.();
156
+ }),
157
+ ]);
158
+ Logger.info('Closed shared Redis connection');
159
+ }
160
+ catch (err) {
161
+ Logger.warn('BullMQ shared Redis graceful shutdown failed, forcing disconnect', err);
162
+ try {
163
+ const disconnect = client.disconnect;
164
+ if (typeof disconnect === 'function')
165
+ disconnect.call(client);
166
+ }
167
+ catch (disconnectError) {
168
+ Logger.error('Failed to force disconnect BullMQ shared Redis connection', disconnectError);
169
+ }
170
+ }
171
+ finally {
172
+ if (timeoutId !== undefined) {
173
+ globalThis.clearTimeout(timeoutId);
174
+ }
175
+ sharedConnection = null;
176
+ }
177
+ };
143
178
  const shutdown = async () => {
144
179
  Logger.info('BullMQRedisQueue shutting down...');
145
180
  // Close all queues in parallel
@@ -156,14 +191,7 @@ export const BullMQRedisQueue = (() => {
156
191
  queues.clear();
157
192
  // Close shared connection
158
193
  if (sharedConnection) {
159
- try {
160
- await sharedConnection.quit();
161
- sharedConnection = null;
162
- Logger.info('Closed shared Redis connection');
163
- }
164
- catch (err) {
165
- Logger.error('Failed to close shared Redis connection', err);
166
- }
194
+ await closeSharedConnection(sharedConnection);
167
195
  }
168
196
  };
169
197
  const getQueue = (queueName) => {
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@zintrust/queue-redis",
3
- "version": "1.5.0",
4
- "buildDate": "2026-04-24T13:05:56.910Z",
3
+ "version": "1.6.0",
4
+ "buildDate": "2026-04-29T16:57:48.361Z",
5
5
  "buildEnvironment": {
6
6
  "node": "v20.20.2",
7
7
  "platform": "linux",
8
8
  "arch": "x64"
9
9
  },
10
10
  "git": {
11
- "commit": "739aa697",
11
+ "commit": "bcc45109",
12
12
  "branch": "master"
13
13
  },
14
14
  "package": {
@@ -29,8 +29,8 @@
29
29
  "sha256": "52fb0f688cd17cc7d8e8128e60df6f5eea4c803282382ac75550e6aacee7cbb0"
30
30
  },
31
31
  "BullMQRedisQueue.js": {
32
- "size": 21981,
33
- "sha256": "b72bda67ed62205f419775dc89373e4c20023fb2f92fa99faa6bfebb853f5635"
32
+ "size": 23135,
33
+ "sha256": "17a005057335d49977a897d7b3d81248aad5f9780d7a6978aad617843f31f0d1"
34
34
  },
35
35
  "HttpQueueDriver.d.ts": {
36
36
  "size": 835,
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "index.js": {
64
64
  "size": 676,
65
- "sha256": "07d5203c2abdcb1a9dbb8da98d188e39c754230f3166575d8b32376569048488"
65
+ "sha256": "ec21ac07641d4300d3ca7e317fcf146e28a59223928f62831f3c34038c4b6e41"
66
66
  },
67
67
  "register.d.ts": {
68
68
  "size": 170,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zintrust/queue-redis",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Redis queue driver for ZinTrust.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  "node": ">=20.0.0"
24
24
  },
25
25
  "peerDependencies": {
26
- "@zintrust/core": "^1.2.0"
26
+ "@zintrust/core": "*"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"