kuzzle 2.61.0 → 2.61.1-beta.1
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/dist/lib/cluster/publisher.js +1 -1
- package/dist/lib/cluster/workers/IDCardRenewer.d.ts +7 -0
- package/dist/lib/cluster/workers/IDCardRenewer.js +32 -2
- package/dist/lib/core/network/httpRouter/index.js +2 -1
- package/dist/lib/service/cache/redis.d.ts +2 -0
- package/dist/lib/service/cache/redis.js +7 -2
- package/dist/package.json +4 -4
- package/package.json +4 -4
|
@@ -364,7 +364,7 @@ class ClusterPublisher {
|
|
|
364
364
|
// (don't), then you have to first make a local copy of this.lastMessageId
|
|
365
365
|
// to make sure that the value returned to the caller has not been
|
|
366
366
|
// increased by other calls
|
|
367
|
-
this.bufferSend(topic, buffer);
|
|
367
|
+
void this.bufferSend(topic, buffer);
|
|
368
368
|
return this.lastMessageId;
|
|
369
369
|
}
|
|
370
370
|
/**
|
|
@@ -35,6 +35,13 @@ declare class IDCardRenewer {
|
|
|
35
35
|
refreshMultiplier: number;
|
|
36
36
|
/** Disposed until `init()` says otherwise. */
|
|
37
37
|
disposed: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* How long a single redis command may take, in ms. Renewals are spaced by
|
|
40
|
+
* `refreshDelay`: one still pending when the next is due is already late,
|
|
41
|
+
* and since the card outlives its last renewal by `refreshMultiplier` (≥ 2)
|
|
42
|
+
* delays, giving up then reports the failure no later than the card expires.
|
|
43
|
+
*/
|
|
44
|
+
get commandTimeout(): number;
|
|
38
45
|
init(config: IDCardRenewerConfig): Promise<void>;
|
|
39
46
|
initRedis(config?: RedisServiceConfig, name?: string): Promise<void>;
|
|
40
47
|
renewIDCard(): Promise<void>;
|
|
@@ -22,6 +22,22 @@ const redis_1 = __importDefault(require("../../service/cache/redis"));
|
|
|
22
22
|
function messageOf(thrown) {
|
|
23
23
|
return thrown instanceof Error ? thrown.message : (0, node_util_1.inspect)(thrown);
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Settles like `pending`, or rejects with `timeout` once `ms` have elapsed.
|
|
27
|
+
* The timer is cleared either way, so a settled race leaves nothing armed.
|
|
28
|
+
*/
|
|
29
|
+
async function withTimeout(pending, ms) {
|
|
30
|
+
let timer;
|
|
31
|
+
const expired = new Promise((_, reject) => {
|
|
32
|
+
timer = setTimeout(() => reject(new Error("timeout")), ms);
|
|
33
|
+
});
|
|
34
|
+
try {
|
|
35
|
+
return await Promise.race([pending, expired]);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
25
41
|
class IDCardRenewer {
|
|
26
42
|
constructor() {
|
|
27
43
|
this.redis = null;
|
|
@@ -33,6 +49,15 @@ class IDCardRenewer {
|
|
|
33
49
|
/** Disposed until `init()` says otherwise. */
|
|
34
50
|
this.disposed = true;
|
|
35
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* How long a single redis command may take, in ms. Renewals are spaced by
|
|
54
|
+
* `refreshDelay`: one still pending when the next is due is already late,
|
|
55
|
+
* and since the card outlives its last renewal by `refreshMultiplier` (≥ 2)
|
|
56
|
+
* delays, giving up then reports the failure no later than the card expires.
|
|
57
|
+
*/
|
|
58
|
+
get commandTimeout() {
|
|
59
|
+
return this.refreshDelay;
|
|
60
|
+
}
|
|
36
61
|
async init(config) {
|
|
37
62
|
if (!this.disposed) {
|
|
38
63
|
return; // Already initialized
|
|
@@ -100,7 +125,10 @@ class IDCardRenewer {
|
|
|
100
125
|
return;
|
|
101
126
|
}
|
|
102
127
|
try {
|
|
103
|
-
|
|
128
|
+
// Bounded (#3181): a redis that stops answering without closing the
|
|
129
|
+
// socket leaves the command queued until the OS gives up on the TCP
|
|
130
|
+
// connection, about 10 minutes, while the card expires within seconds.
|
|
131
|
+
const refreshed = await withTimeout(this.redis.commands.pexpire(this.nodeIdKey, this.refreshDelay * this.refreshMultiplier), this.commandTimeout);
|
|
104
132
|
// Unable to refresh the key in time before it expires
|
|
105
133
|
// => this node is too slow, we need to remove it from the cluster
|
|
106
134
|
if (refreshed === 0) {
|
|
@@ -136,7 +164,9 @@ class IDCardRenewer {
|
|
|
136
164
|
return;
|
|
137
165
|
}
|
|
138
166
|
try {
|
|
139
|
-
|
|
167
|
+
// Bounded too: a failed renewal is reported to the parent only once
|
|
168
|
+
// this returns, and the redis that made it fail is likely still mute.
|
|
169
|
+
await withTimeout(this.redis.commands.del(this.nodeIdKey), this.commandTimeout);
|
|
140
170
|
}
|
|
141
171
|
catch (error) {
|
|
142
172
|
// eslint-disable-next-line no-console
|
|
@@ -156,7 +156,8 @@ class Router {
|
|
|
156
156
|
if (message.method === "OPTIONS") {
|
|
157
157
|
request.input.headers = message.headers;
|
|
158
158
|
request.response.configure({ result: {}, status: 200 });
|
|
159
|
-
|
|
159
|
+
// With a callback, `pipe` answers through it and returns no promise
|
|
160
|
+
void global.kuzzle.pipe("http:options", request, (error, result) => {
|
|
160
161
|
if (error) {
|
|
161
162
|
replyWithError(cb, request, error);
|
|
162
163
|
}
|
|
@@ -246,12 +246,17 @@ class Redis extends service_1.default {
|
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
+
// Valkey reports `redis_version:7.2.4` whatever its own version, for the
|
|
250
|
+
// clients that check it: its version is `valkey_version`. Valkey 9 also
|
|
251
|
+
// renamed `redis_mode` to `server_mode`.
|
|
252
|
+
const isValkey = info.server_name === "valkey";
|
|
249
253
|
return {
|
|
250
254
|
memoryPeak: info.used_memory_peak_human ?? "",
|
|
251
255
|
memoryUsed: info.used_memory_human ?? "",
|
|
252
|
-
mode: info.redis_mode ?? "",
|
|
256
|
+
mode: info.redis_mode ?? info.server_mode ?? "",
|
|
257
|
+
server: isValkey ? "valkey" : "redis",
|
|
253
258
|
type: "redis",
|
|
254
|
-
version: info.redis_version ?? "",
|
|
259
|
+
version: (isValkey ? info.valkey_version : info.redis_version) ?? "",
|
|
255
260
|
};
|
|
256
261
|
}
|
|
257
262
|
/**
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle",
|
|
3
3
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
4
|
-
"version": "2.61.
|
|
4
|
+
"version": "2.61.1-beta.1",
|
|
5
5
|
"description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rm -Rf ./dist && tsc && node -r ts-node/register/transpile-only ./bin/copy-binaries.ts",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"kuzzle-logger": "1.7.0",
|
|
53
53
|
"kuzzle-plugin-auth-passport-local": "6.4.1",
|
|
54
54
|
"kuzzle-sdk": ">=7.17.1 <8.0.0",
|
|
55
|
-
"kuzzle-storage-es-7": "1.1.
|
|
56
|
-
"kuzzle-storage-es-8": "1.1.
|
|
55
|
+
"kuzzle-storage-es-7": "1.1.1",
|
|
56
|
+
"kuzzle-storage-es-8": "1.1.1",
|
|
57
57
|
"kuzzle-types": "^1.0.0",
|
|
58
58
|
"kuzzle-vault": "2.2.0",
|
|
59
59
|
"lodash": "4.18.1",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"prettier": "3.9.10",
|
|
101
101
|
"protobufjs-v7": "npm:protobufjs@7.5.4",
|
|
102
102
|
"request-promise": "4.2.6",
|
|
103
|
-
"semantic-release-config-kuzzle": "1.
|
|
103
|
+
"semantic-release-config-kuzzle": "1.9.0",
|
|
104
104
|
"should": "13.2.3",
|
|
105
105
|
"strip-json-comments": "5.0.3",
|
|
106
106
|
"ts-node": "10.9.2",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle",
|
|
3
3
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
4
|
-
"version": "2.61.
|
|
4
|
+
"version": "2.61.1-beta.1",
|
|
5
5
|
"description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rm -Rf ./dist && tsc && node -r ts-node/register/transpile-only ./bin/copy-binaries.ts",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"kuzzle-logger": "1.7.0",
|
|
53
53
|
"kuzzle-plugin-auth-passport-local": "6.4.1",
|
|
54
54
|
"kuzzle-sdk": ">=7.17.1 <8.0.0",
|
|
55
|
-
"kuzzle-storage-es-7": "1.1.
|
|
56
|
-
"kuzzle-storage-es-8": "1.1.
|
|
55
|
+
"kuzzle-storage-es-7": "1.1.1",
|
|
56
|
+
"kuzzle-storage-es-8": "1.1.1",
|
|
57
57
|
"kuzzle-types": "^1.0.0",
|
|
58
58
|
"kuzzle-vault": "2.2.0",
|
|
59
59
|
"lodash": "4.18.1",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"prettier": "3.9.10",
|
|
101
101
|
"protobufjs-v7": "npm:protobufjs@7.5.4",
|
|
102
102
|
"request-promise": "4.2.6",
|
|
103
|
-
"semantic-release-config-kuzzle": "1.
|
|
103
|
+
"semantic-release-config-kuzzle": "1.9.0",
|
|
104
104
|
"should": "13.2.3",
|
|
105
105
|
"strip-json-comments": "5.0.3",
|
|
106
106
|
"ts-node": "10.9.2",
|