@imqueue/core 3.2.3 → 3.2.4
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/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
|
+
## [Unreleased]
|
|
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.4",
|
|
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/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
|