kuzzle 2.61.2-beta.1 → 2.61.2

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.
@@ -62,6 +62,7 @@ const lodash_1 = __importDefault(require("lodash"));
62
62
  const ms_1 = __importDefault(require("ms"));
63
63
  const kerror = __importStar(require("../../kerror"));
64
64
  const errors_1 = require("../../kerror/errors");
65
+ const isCacheTimeout_1 = require("../../kerror/isCacheTimeout");
65
66
  const token_1 = require("../../model/security/token");
66
67
  const apiKey_1 = __importDefault(require("../../model/storage/apiKey"));
67
68
  const ObjectRepository_1 = require("../shared/ObjectRepository");
@@ -300,7 +301,9 @@ class TokenRepository extends ObjectRepository_1.ObjectRepository {
300
301
  return await this.loadForUser(userId, token);
301
302
  }
302
303
  catch (err) {
303
- if (err instanceof errors_1.UnauthorizedError) {
304
+ // The cache server not answering is a 503 the client can retry, not
305
+ // a verification failure (500)
306
+ if (err instanceof errors_1.UnauthorizedError || (0, isCacheTimeout_1.isCacheTimeout)(err)) {
304
307
  throw err;
305
308
  }
306
309
  throw securityError.getFrom(err instanceof Error ? err : new Error(String(err)), "verification_error", err instanceof Error ? err.message : String(err));
@@ -55,6 +55,7 @@ var __importStar = (this && this.__importStar) || (function () {
55
55
  Object.defineProperty(exports, "__esModule", { value: true });
56
56
  exports.ObjectRepository = void 0;
57
57
  const kerror = __importStar(require("../../kerror"));
58
+ const isCacheTimeout_1 = require("../../kerror/isCacheTimeout");
58
59
  const cacheDbEnum_1 = require("../cache/cacheDbEnum");
59
60
  /**
60
61
  * `_id` is nullable because the models are: `User`, `Profile` and `Token` are
@@ -142,6 +143,11 @@ class ObjectRepository {
142
143
  return await this.fromDTO({ ...JSON.parse(response) });
143
144
  }
144
145
  catch (err) {
146
+ // The cache server not answering is a 503 the client can retry, not
147
+ // a read failure (500)
148
+ if ((0, isCacheTimeout_1.isCacheTimeout)(err)) {
149
+ throw err;
150
+ }
145
151
  throw kerror.get("services", "cache", "read_failed", err instanceof Error ? err.message : String(err));
146
152
  }
147
153
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Whether an error is the cache server not answering within the opt-in
3
+ * ioredis `commandTimeout` (`services.cache.timeout`, 503). Code that wraps
4
+ * cache errors into its own lets this one through, so the client gets the
5
+ * 503 it can retry instead of a 500.
6
+ */
7
+ export declare function isCacheTimeout(error: unknown): boolean;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /*
3
+ * Kuzzle, a backend software, self-hostable and ready to use
4
+ * to power modern apps
5
+ *
6
+ * Copyright 2015-2022 Kuzzle
7
+ * mailto: support AT kuzzle.io
8
+ * website: http://kuzzle.io
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * https://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.isCacheTimeout = isCacheTimeout;
24
+ const errors_1 = require("./errors");
25
+ /**
26
+ * Whether an error is the cache server not answering within the opt-in
27
+ * ioredis `commandTimeout` (`services.cache.timeout`, 503). Code that wraps
28
+ * cache errors into its own lets this one through, so the client gets the
29
+ * 503 it can retry instead of a 500.
30
+ */
31
+ function isCacheTimeout(error) {
32
+ return error instanceof errors_1.KuzzleError && error.id === "services.cache.timeout";
33
+ }
34
+ //# sourceMappingURL=isCacheTimeout.js.map
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.2-beta.1",
4
+ "version": "2.61.2",
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",
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.2-beta.1",
4
+ "version": "2.61.2",
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",