kuzzle 2.61.0-beta.6 → 2.61.0-beta.8
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/api/funnel.d.ts +5 -0
- package/dist/lib/api/funnel.js +9 -0
- package/dist/lib/kuzzle/kuzzle.js +23 -0
- package/dist/package.json +3 -3
- package/package.json +3 -3
package/dist/lib/api/funnel.d.ts
CHANGED
|
@@ -30,6 +30,11 @@ type DocumentEventAliases = EventAliases & {
|
|
|
30
30
|
declare class Funnel {
|
|
31
31
|
overloaded: boolean;
|
|
32
32
|
concurrentRequests: number;
|
|
33
|
+
/**
|
|
34
|
+
* Plugin requests running outside `processRequest` (the event-less path of
|
|
35
|
+
* `executePluginRequest`): not limited, waited for on shutdown (#3160)
|
|
36
|
+
*/
|
|
37
|
+
pluginRequests: number;
|
|
33
38
|
controllers: Map<string, NativeController>;
|
|
34
39
|
pendingRequestsQueue: Deque<string>;
|
|
35
40
|
pendingRequestsById: Map<string, PendingRequest>;
|
package/dist/lib/api/funnel.js
CHANGED
|
@@ -113,6 +113,11 @@ class Funnel {
|
|
|
113
113
|
constructor() {
|
|
114
114
|
this.overloaded = false;
|
|
115
115
|
this.concurrentRequests = 0;
|
|
116
|
+
/**
|
|
117
|
+
* Plugin requests running outside `processRequest` (the event-less path of
|
|
118
|
+
* `executePluginRequest`): not limited, waited for on shutdown (#3160)
|
|
119
|
+
*/
|
|
120
|
+
this.pluginRequests = 0;
|
|
116
121
|
this.controllers = new Map();
|
|
117
122
|
this.pendingRequestsQueue = new denque_1.default();
|
|
118
123
|
this.pendingRequestsById = new Map();
|
|
@@ -685,6 +690,7 @@ class Funnel {
|
|
|
685
690
|
});
|
|
686
691
|
}
|
|
687
692
|
}
|
|
693
|
+
this.pluginRequests++;
|
|
688
694
|
try {
|
|
689
695
|
return await doAction(this.getController(request), request);
|
|
690
696
|
}
|
|
@@ -692,6 +698,9 @@ class Funnel {
|
|
|
692
698
|
this.handleErrorDump((0, thrown_1.causeOf)(e));
|
|
693
699
|
throw e;
|
|
694
700
|
}
|
|
701
|
+
finally {
|
|
702
|
+
this.pluginRequests--;
|
|
703
|
+
}
|
|
695
704
|
}
|
|
696
705
|
async handleProcessRequestError(modifiedRequest, request, error) {
|
|
697
706
|
let _error = this._wrapError(request, error);
|
|
@@ -100,6 +100,12 @@ let _kuzzle = null;
|
|
|
100
100
|
* not keep a failed node alive, which a bare `process.exit(1)` never did
|
|
101
101
|
*/
|
|
102
102
|
const FAILURE_SHUTDOWN_TIMEOUT = 30000;
|
|
103
|
+
/**
|
|
104
|
+
* How long a shutdown waits for the plugin requests still running before it
|
|
105
|
+
* closes the storage: plugins may run requests in a loop, and nothing refuses
|
|
106
|
+
* them on shutdown, so the wait is bounded (#3160)
|
|
107
|
+
*/
|
|
108
|
+
const PLUGIN_REQUESTS_SHUTDOWN_TIMEOUT = 5000;
|
|
103
109
|
/**
|
|
104
110
|
* Stops the startup sequence once a shutdown has begun (#3045): `start()`
|
|
105
111
|
* catches it and leaves the shutdown to end the process. Internal: never
|
|
@@ -353,6 +359,16 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
|
|
|
353
359
|
this.log.info(`[shutdown] Waiting: ${this.funnel.remainingRequests} remaining requests`);
|
|
354
360
|
await bluebird_1.default.delay(1000);
|
|
355
361
|
}
|
|
362
|
+
// The storage closes below: let the plugin requests in progress finish
|
|
363
|
+
// (#3160)
|
|
364
|
+
const pluginRequestsDeadline = Date.now() + PLUGIN_REQUESTS_SHUTDOWN_TIMEOUT;
|
|
365
|
+
while (this.funnel.pluginRequests > 0 &&
|
|
366
|
+
Date.now() < pluginRequestsDeadline) {
|
|
367
|
+
await bluebird_1.default.delay(100); // NOSONAR: sequential polling, by design
|
|
368
|
+
}
|
|
369
|
+
if (this.funnel.pluginRequests > 0) {
|
|
370
|
+
this.log.warn(`[shutdown] ${this.funnel.pluginRequests} plugin requests still running after ${PLUGIN_REQUESTS_SHUTDOWN_TIMEOUT}ms: closing the storage anyway`);
|
|
371
|
+
}
|
|
356
372
|
// The other nodes may be waiting on a lock this one holds: a node leaving
|
|
357
373
|
// mid-startup is often in the middle of one (F-13).
|
|
358
374
|
await Promise.all([
|
|
@@ -679,6 +695,13 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
|
|
|
679
695
|
else {
|
|
680
696
|
this.log.error(`ERROR: unhandledRejection: ${promise}`);
|
|
681
697
|
}
|
|
698
|
+
// A shutdown already in progress has closed, or is closing, what late
|
|
699
|
+
// work may still use (the network, the storage): crashing would turn a
|
|
700
|
+
// requested shutdown into a failure, so the rejection is only logged
|
|
701
|
+
// (#3160)
|
|
702
|
+
if (this._state === kuzzleStateEnum_1.default.SHUTTING_DOWN) {
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
682
705
|
// Crashing on an unhandled rejection is a good idea during development
|
|
683
706
|
// as it helps spotting code errors. And according to the warning messages,
|
|
684
707
|
// this is what Node.js will do automatically in future versions anyway.
|
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-beta.
|
|
4
|
+
"version": "2.61.0-beta.8",
|
|
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.0",
|
|
56
|
+
"kuzzle-storage-es-8": "1.1.0",
|
|
57
57
|
"kuzzle-types": "^1.0.0",
|
|
58
58
|
"kuzzle-vault": "2.2.0",
|
|
59
59
|
"lodash": "4.18.1",
|
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-beta.
|
|
4
|
+
"version": "2.61.0-beta.8",
|
|
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.0",
|
|
56
|
+
"kuzzle-storage-es-8": "1.1.0",
|
|
57
57
|
"kuzzle-types": "^1.0.0",
|
|
58
58
|
"kuzzle-vault": "2.2.0",
|
|
59
59
|
"lodash": "4.18.1",
|