ioredis 5.8.0 → 5.8.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.
package/built/Command.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export interface CommandNameFlags {
|
|
|
30
30
|
ENTER_SUBSCRIBER_MODE: ["subscribe", "psubscribe", "ssubscribe"];
|
|
31
31
|
EXIT_SUBSCRIBER_MODE: ["unsubscribe", "punsubscribe", "sunsubscribe"];
|
|
32
32
|
WILL_DISCONNECT: ["quit"];
|
|
33
|
+
HANDSHAKE_COMMANDS: ["auth", "select", "client", "readonly", "info"];
|
|
34
|
+
IGNORE_RECONNECT_ON_ERROR: ["client"];
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
35
37
|
* Command instance
|
package/built/Command.js
CHANGED
|
@@ -270,6 +270,8 @@ Command.FLAGS = {
|
|
|
270
270
|
ENTER_SUBSCRIBER_MODE: ["subscribe", "psubscribe", "ssubscribe"],
|
|
271
271
|
EXIT_SUBSCRIBER_MODE: ["unsubscribe", "punsubscribe", "sunsubscribe"],
|
|
272
272
|
WILL_DISCONNECT: ["quit"],
|
|
273
|
+
HANDSHAKE_COMMANDS: ["auth", "select", "client", "readonly", "info"],
|
|
274
|
+
IGNORE_RECONNECT_ON_ERROR: ["client"],
|
|
273
275
|
};
|
|
274
276
|
Command._transformer = {
|
|
275
277
|
argument: {},
|
package/built/Redis.js
CHANGED
|
@@ -345,7 +345,8 @@ class Redis extends Commander_1.default {
|
|
|
345
345
|
(!stream &&
|
|
346
346
|
this.status === "connect" &&
|
|
347
347
|
(0, commands_1.exists)(command.name) &&
|
|
348
|
-
(0, commands_1.hasFlag)(command.name, "loading")
|
|
348
|
+
((0, commands_1.hasFlag)(command.name, "loading") ||
|
|
349
|
+
Command_1.default.checkFlag("HANDSHAKE_COMMANDS", command.name)));
|
|
349
350
|
if (!this.stream) {
|
|
350
351
|
writable = false;
|
|
351
352
|
}
|
|
@@ -501,7 +502,8 @@ class Redis extends Commander_1.default {
|
|
|
501
502
|
handleReconnection(err, item) {
|
|
502
503
|
var _a;
|
|
503
504
|
let needReconnect = false;
|
|
504
|
-
if (this.options.reconnectOnError
|
|
505
|
+
if (this.options.reconnectOnError &&
|
|
506
|
+
!Command_1.default.checkFlag("IGNORE_RECONNECT_ON_ERROR", item.command.name)) {
|
|
505
507
|
needReconnect = this.options.reconnectOnError(err);
|
|
506
508
|
}
|
|
507
509
|
switch (needReconnect) {
|
package/built/autoPipelining.js
CHANGED
|
@@ -158,9 +158,27 @@ class ClusterSubscriber {
|
|
|
158
158
|
let pending = 0;
|
|
159
159
|
for (const type of ["subscribe", "psubscribe", "ssubscribe"]) {
|
|
160
160
|
const channels = previousChannels[type];
|
|
161
|
-
if (channels.length) {
|
|
161
|
+
if (channels.length == 0) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
debug("%s %d channels", type, channels.length);
|
|
165
|
+
if (type === "ssubscribe") {
|
|
166
|
+
for (const channel of channels) {
|
|
167
|
+
pending += 1;
|
|
168
|
+
this.subscriber[type](channel)
|
|
169
|
+
.then(() => {
|
|
170
|
+
if (!--pending) {
|
|
171
|
+
this.lastActiveSubscriber = this.subscriber;
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
.catch(() => {
|
|
175
|
+
// TODO: should probably disconnect the subscriber and try again.
|
|
176
|
+
debug("failed to ssubscribe to channel: %s", channel);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
162
181
|
pending += 1;
|
|
163
|
-
debug("%s %d channels", type, channels.length);
|
|
164
182
|
this.subscriber[type](channels)
|
|
165
183
|
.then(() => {
|
|
166
184
|
if (!--pending) {
|
|
@@ -9,6 +9,7 @@ const DataHandler_1 = require("../DataHandler");
|
|
|
9
9
|
const debug = (0, utils_1.Debug)("connection");
|
|
10
10
|
function connectHandler(self) {
|
|
11
11
|
return function () {
|
|
12
|
+
var _a;
|
|
12
13
|
self.setStatus("connect");
|
|
13
14
|
self.resetCommandQueue();
|
|
14
15
|
// AUTH command should be processed before any other commands
|
|
@@ -43,9 +44,6 @@ function connectHandler(self) {
|
|
|
43
44
|
self.silentEmit("error", err);
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
|
-
if (!self.options.enableReadyCheck) {
|
|
47
|
-
exports.readyHandler(self)();
|
|
48
|
-
}
|
|
49
47
|
/*
|
|
50
48
|
No need to keep the reference of DataHandler here
|
|
51
49
|
because we don't need to do the cleanup.
|
|
@@ -54,26 +52,53 @@ function connectHandler(self) {
|
|
|
54
52
|
new DataHandler_1.default(self, {
|
|
55
53
|
stringNumbers: self.options.stringNumbers,
|
|
56
54
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
const clientCommandPromises = [];
|
|
56
|
+
if (self.options.connectionName) {
|
|
57
|
+
debug("set the connection name [%s]", self.options.connectionName);
|
|
58
|
+
clientCommandPromises.push(self.client("setname", self.options.connectionName).catch(utils_1.noop));
|
|
59
|
+
}
|
|
60
|
+
if (!self.options.disableClientInfo) {
|
|
61
|
+
debug("set the client info");
|
|
62
|
+
clientCommandPromises.push((0, utils_1.getPackageMeta)()
|
|
63
|
+
.then((packageMeta) => {
|
|
64
|
+
return self
|
|
65
|
+
.client("SETINFO", "LIB-VER", packageMeta.version)
|
|
66
|
+
.catch(utils_1.noop);
|
|
67
|
+
})
|
|
68
|
+
.catch(utils_1.noop));
|
|
69
|
+
clientCommandPromises.push(self
|
|
70
|
+
.client("SETINFO", "LIB-NAME", ((_a = self.options) === null || _a === void 0 ? void 0 : _a.clientInfoTag)
|
|
71
|
+
? `ioredis(${self.options.clientInfoTag})`
|
|
72
|
+
: "ioredis")
|
|
73
|
+
.catch(utils_1.noop));
|
|
74
|
+
}
|
|
75
|
+
Promise.all(clientCommandPromises)
|
|
76
|
+
.catch(utils_1.noop)
|
|
77
|
+
.finally(() => {
|
|
78
|
+
if (!self.options.enableReadyCheck) {
|
|
79
|
+
exports.readyHandler(self)();
|
|
80
|
+
}
|
|
81
|
+
if (self.options.enableReadyCheck) {
|
|
82
|
+
self._readyCheck(function (err, info) {
|
|
83
|
+
if (connectionEpoch !== self.connectionEpoch) {
|
|
84
|
+
return;
|
|
65
85
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
86
|
+
if (err) {
|
|
87
|
+
if (!flushed) {
|
|
88
|
+
self.recoverFromFatalError(new Error("Ready check failed: " + err.message), err);
|
|
89
|
+
}
|
|
70
90
|
}
|
|
71
91
|
else {
|
|
72
|
-
self.
|
|
92
|
+
if (self.connector.check(info)) {
|
|
93
|
+
exports.readyHandler(self)();
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
self.disconnect(true);
|
|
97
|
+
}
|
|
73
98
|
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
77
102
|
};
|
|
78
103
|
}
|
|
79
104
|
exports.connectHandler = connectHandler;
|
|
@@ -199,7 +224,6 @@ function errorHandler(self) {
|
|
|
199
224
|
exports.errorHandler = errorHandler;
|
|
200
225
|
function readyHandler(self) {
|
|
201
226
|
return function () {
|
|
202
|
-
var _a, _b;
|
|
203
227
|
self.setStatus("ready");
|
|
204
228
|
self.retryAttempts = 0;
|
|
205
229
|
if (self.options.monitor) {
|
|
@@ -220,29 +244,6 @@ function readyHandler(self) {
|
|
|
220
244
|
const finalSelect = self.prevCondition
|
|
221
245
|
? self.prevCondition.select
|
|
222
246
|
: self.condition.select;
|
|
223
|
-
if (self.options.connectionName) {
|
|
224
|
-
debug("set the connection name [%s]", self.options.connectionName);
|
|
225
|
-
self.client("setname", self.options.connectionName).catch(utils_1.noop);
|
|
226
|
-
}
|
|
227
|
-
if (!((_a = self.options) === null || _a === void 0 ? void 0 : _a.disableClientInfo)) {
|
|
228
|
-
debug("set the client info");
|
|
229
|
-
let version = null;
|
|
230
|
-
(0, utils_1.getPackageMeta)()
|
|
231
|
-
.then((packageMeta) => {
|
|
232
|
-
version = packageMeta === null || packageMeta === void 0 ? void 0 : packageMeta.version;
|
|
233
|
-
})
|
|
234
|
-
.catch(utils_1.noop)
|
|
235
|
-
.finally(() => {
|
|
236
|
-
self
|
|
237
|
-
.client("SETINFO", "LIB-VER", version)
|
|
238
|
-
.catch(utils_1.noop);
|
|
239
|
-
});
|
|
240
|
-
self
|
|
241
|
-
.client("SETINFO", "LIB-NAME", ((_b = self.options) === null || _b === void 0 ? void 0 : _b.clientInfoTag)
|
|
242
|
-
? `ioredis(${self.options.clientInfoTag})`
|
|
243
|
-
: "ioredis")
|
|
244
|
-
.catch(utils_1.noop);
|
|
245
|
-
}
|
|
246
247
|
if (self.options.readOnly) {
|
|
247
248
|
debug("set the connection to readonly mode");
|
|
248
249
|
self.readonly().catch(utils_1.noop);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ioredis",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.2",
|
|
4
4
|
"description": "A robust, performance-focused and full-featured Redis client for Node.js.",
|
|
5
5
|
"main": "./built/index.js",
|
|
6
6
|
"types": "./built/index.d.ts",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"built/"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"docker:setup": "docker compose -f test/docker-compose.yml up -d --wait",
|
|
12
|
+
"docker:teardown": "docker compose -f test/docker-compose.yml down --volumes --remove-orphans",
|
|
13
13
|
"test:tsd": "npm run build && tsd",
|
|
14
|
-
"test:js": "TS_NODE_TRANSPILE_ONLY=true NODE_ENV=test mocha \"test/helpers/*.ts\" \"test/unit/**/*.ts\" \"test/functional/**/*.ts\"",
|
|
14
|
+
"test:js": "TS_NODE_TRANSPILE_ONLY=true NODE_ENV=test mocha --no-experimental-strip-types \"test/helpers/*.ts\" \"test/unit/**/*.ts\" \"test/functional/**/*.ts\"",
|
|
15
15
|
"test:cov": "nyc npm run test:js",
|
|
16
|
-
"test:cluster": "TS_NODE_TRANSPILE_ONLY=true NODE_ENV=test mocha \"test/cluster/**/*.ts\"",
|
|
16
|
+
"test:cluster": "TS_NODE_TRANSPILE_ONLY=true NODE_ENV=test mocha --no-experimental-strip-types \"test/cluster/**/*.ts\"",
|
|
17
17
|
"test": "npm run test:js && npm run test:tsd",
|
|
18
18
|
"lint": "eslint --ext .js,.ts ./lib",
|
|
19
19
|
"docs": "npx typedoc --logLevel Error --excludeExternals --excludeProtected --excludePrivate --readme none lib/index.ts",
|