ioredis 4.24.1 → 4.24.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/Changelog.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [4.24.2](https://github.com/luin/ioredis/compare/v4.24.1...v4.24.2) (2021-03-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * properly handle instant stream errors ([#1299](https://github.com/luin/ioredis/issues/1299)) ([0327ef5](https://github.com/luin/ioredis/commit/0327ef5a57481042d3f7d306917f55ef04f3a6cc))
7
+
1
8
  ## [4.24.1](https://github.com/luin/ioredis/compare/v4.24.0...v4.24.1) (2021-03-14)
2
9
 
3
10
 
@@ -78,6 +78,9 @@ class SentinelConnector extends AbstractConnector_1.default {
78
78
  else {
79
79
  this.stream = net_1.createConnection(resolved);
80
80
  }
81
+ this.stream.once("error", (err) => {
82
+ this.firstError = err;
83
+ });
81
84
  this.sentinelIterator.reset(true);
82
85
  resolve(this.stream);
83
86
  }
@@ -62,6 +62,9 @@ class StandaloneConnector extends AbstractConnector_1.default {
62
62
  reject(err);
63
63
  return;
64
64
  }
65
+ this.stream.once("error", (err) => {
66
+ this.firstError = err;
67
+ });
65
68
  resolve(this.stream);
66
69
  });
67
70
  });
@@ -320,11 +320,22 @@ Redis.prototype.connect = function (callback) {
320
320
  });
321
321
  }
322
322
  }
323
+ else if (stream.destroyed) {
324
+ const firstError = _this.connector.firstError;
325
+ if (firstError) {
326
+ process.nextTick(() => {
327
+ eventHandler.errorHandler(_this)(firstError);
328
+ });
329
+ }
330
+ process.nextTick(eventHandler.closeHandler(_this));
331
+ }
323
332
  else {
324
333
  process.nextTick(eventHandler.connectHandler(_this));
325
334
  }
326
- stream.once("error", eventHandler.errorHandler(_this));
327
- stream.once("close", eventHandler.closeHandler(_this));
335
+ if (!stream.destroyed) {
336
+ stream.once("error", eventHandler.errorHandler(_this));
337
+ stream.once("close", eventHandler.closeHandler(_this));
338
+ }
328
339
  if (options.noDelay) {
329
340
  stream.setNoDelay(true);
330
341
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ioredis",
3
- "version": "4.24.1",
3
+ "version": "4.24.2",
4
4
  "description": "A robust, performance-focused and full-featured Redis client for Node.js.",
5
5
  "main": "built/index.js",
6
6
  "files": [