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.
@@ -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
- const refreshed = await this.redis.commands.pexpire(this.nodeIdKey, this.refreshDelay * this.refreshMultiplier);
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
- await this.redis.commands.del(this.nodeIdKey);
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
- global.kuzzle.pipe("http:options", request, (error, result) => {
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
  }
@@ -10,6 +10,8 @@ interface RedisInfo {
10
10
  memoryPeak: string;
11
11
  memoryUsed: string;
12
12
  mode: string;
13
+ /** The server answering, from its own report: Redis, or a fork of it */
14
+ server: "redis" | "valkey";
13
15
  type: "redis";
14
16
  version: string;
15
17
  }
@@ -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.0",
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.0",
56
- "kuzzle-storage-es-8": "1.1.0",
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.8.0",
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.0",
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.0",
56
- "kuzzle-storage-es-8": "1.1.0",
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.8.0",
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",