@imqueue/core 3.2.3 → 3.2.5
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.
- package/CHANGELOG.md +28 -0
- package/package.json +1 -1
- package/src/IMessageQueue.d.ts +30 -9
- package/src/RedisQueue.js +17 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Notable changes to `@imqueue/core`. Entries start with the first release whose
|
|
4
|
+
behavior changes needed a written record; earlier history is in the git log.
|
|
5
|
+
|
|
6
|
+
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [3.2.4] - 2026-07-26
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **A destroyed queue could swallow one message addressed to the next owner of
|
|
13
|
+
its queue name.** The reader is the only channel issuing blocking reads
|
|
14
|
+
(`BRPOP`/`BLMOVE` with an infinite timeout), and redis cannot process a `QUIT`
|
|
15
|
+
while one is in flight. The graceful quit therefore never completed, and the
|
|
16
|
+
connection stayed a *registered consumer* of the queue until the
|
|
17
|
+
`IMQ_CONNECTION_QUIT_TIMEOUT` grace period expired — outliving `destroy()`.
|
|
18
|
+
Any message pushed to that key in the meantime went to the dead reader, whose
|
|
19
|
+
read loop was already torn down, and was dropped with no error anywhere.
|
|
20
|
+
|
|
21
|
+
The reader is now disconnected immediately, which unregisters it as a consumer
|
|
22
|
+
without consuming anything. Idle channels are still quit gracefully, with the
|
|
23
|
+
same forced-disconnect fallback as before.
|
|
24
|
+
|
|
25
|
+
This is reachable whenever a queue name is handed over, which is exactly what
|
|
26
|
+
`@imqueue/rpc` does when a client is destroyed and a new one takes its
|
|
27
|
+
identifier — including from another process, where nothing on the rpc side can
|
|
28
|
+
prevent it.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imqueue/core",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.5",
|
|
4
4
|
"description": "Fast JSON message queue over Redis for inter-service communication in Node.js & TypeScript microservices — the transport layer of the @imqueue framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"message-queue",
|
package/src/IMessageQueue.d.ts
CHANGED
|
@@ -203,19 +203,38 @@ export interface IMQOptions extends Partial<IMessageQueueConnection> {
|
|
|
203
203
|
*/
|
|
204
204
|
useGzip?: boolean;
|
|
205
205
|
/**
|
|
206
|
-
* Enable guaranteed message delivery. When enabled,
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* that
|
|
206
|
+
* Enable guaranteed message delivery. When enabled, reading a message
|
|
207
|
+
* moves it atomically out of the queue into a worker-owned key instead of
|
|
208
|
+
* popping it outright, so a worker that dies *before* it starts on a
|
|
209
|
+
* message leaves that message behind for the watcher to re-queue rather
|
|
210
|
+
* than taking it down with the process.
|
|
211
|
+
*
|
|
212
|
+
* The guarantee covers that hand-off, not the processing. The worker key
|
|
213
|
+
* is released as soon as the message is dispatched to the `message`
|
|
214
|
+
* listener, so a worker killed while its handler is still running loses
|
|
215
|
+
* that message exactly as it would with safe delivery off — draining
|
|
216
|
+
* in-flight work before exit is up to the application. Delivery is
|
|
217
|
+
* at-least-once in either mode, so handlers should be idempotent.
|
|
210
218
|
*
|
|
219
|
+
* @default false
|
|
211
220
|
* @type {boolean}
|
|
212
221
|
*/
|
|
213
222
|
safeDelivery?: boolean;
|
|
214
223
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
224
|
+
* Lease deadline (in milliseconds) stamped onto the worker key when
|
|
225
|
+
* safeDelivery moves a message out of the queue, and the interval on which
|
|
226
|
+
* the watcher sweeps for expired keys. A worker key still present once its
|
|
227
|
+
* deadline has passed is treated as abandoned, and its message is moved
|
|
228
|
+
* back onto the main queue.
|
|
229
|
+
*
|
|
230
|
+
* This is a recovery deadline for an abandoned hand-off, not a processing
|
|
231
|
+
* deadline. The key is released when the message is dispatched, so a slow
|
|
232
|
+
* handler is neither interrupted nor re-queued for taking too long, and
|
|
233
|
+
* raising this value extends no protection over long-running work — tune it
|
|
234
|
+
* for how quickly an abandoned message should come back. Only effective
|
|
235
|
+
* when safeDelivery is enabled.
|
|
218
236
|
*
|
|
237
|
+
* @default 5000
|
|
219
238
|
* @type {number}
|
|
220
239
|
*/
|
|
221
240
|
safeDeliveryTtl?: number;
|
|
@@ -234,8 +253,10 @@ export interface IMQOptions extends Partial<IMessageQueueConnection> {
|
|
|
234
253
|
clusterManagers?: ClusterManager[];
|
|
235
254
|
/**
|
|
236
255
|
* Enable process signal handling (SIGTERM, SIGINT, SIGABRT) by the queue.
|
|
237
|
-
* When enabled, the queue releases its watcher lock
|
|
238
|
-
*
|
|
256
|
+
* When enabled, the queue releases its watcher lock on these signals and
|
|
257
|
+
* then exits the process. It does not wait for in-flight `message` handlers
|
|
258
|
+
* to finish, so drain those yourself if work in progress must not be lost.
|
|
259
|
+
* Disable if the host application manages shutdown.
|
|
239
260
|
*
|
|
240
261
|
* @default true
|
|
241
262
|
* @type {boolean}
|
package/src/RedisQueue.js
CHANGED
|
@@ -877,10 +877,23 @@ let RedisQueue = (() => {
|
|
|
877
877
|
this.verbose(`Error disconnecting ${channel}: ${error}`);
|
|
878
878
|
}
|
|
879
879
|
};
|
|
880
|
-
//
|
|
881
|
-
//
|
|
882
|
-
//
|
|
883
|
-
// the
|
|
880
|
+
// The reader is the only channel that issues blocking reads
|
|
881
|
+
// (BRPOP/BLMOVE with an infinite timeout), and redis cannot process
|
|
882
|
+
// a QUIT while one is in flight. Asking politely therefore buys
|
|
883
|
+
// nothing and costs: until the grace period expires the socket
|
|
884
|
+
// remains a *registered consumer* of the queue, so redis hands it
|
|
885
|
+
// the next message pushed there and the read loop, already torn
|
|
886
|
+
// down, drops it. Whoever owns that queue name by then - a new
|
|
887
|
+
// client that took the name over, in this process or another -
|
|
888
|
+
// silently loses one message. So drop the reader at once, which
|
|
889
|
+
// unregisters it as a consumer without consuming anything.
|
|
890
|
+
if (channel === 'reader') {
|
|
891
|
+
forceDisconnect();
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
// idle channels can complete a graceful quit, but still guarantee a
|
|
895
|
+
// forced disconnect after a short grace period to avoid leaking the
|
|
896
|
+
// socket (which would keep the process alive)
|
|
884
897
|
client.quit().then(forceDisconnect, forceDisconnect);
|
|
885
898
|
const timer = setTimeout(forceDisconnect, IMQ_CONNECTION_QUIT_TIMEOUT);
|
|
886
899
|
// the grace timer itself must not keep the process alive; while
|