Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If network goes down during connection to a redis instance, process crashes #80

Closed
AVVS opened this issue Jun 24, 2015 · 3 comments
Closed

Comments

@AVVS
Copy link
Collaborator

AVVS commented Jun 24, 2015

I wouldn't say that this is really going to happen in the real-life, and probably if it did, the machine is not reachable from the outside, but I think it's not the worst idea to report.

To replicate this - start redis process, make sure it tries to reach something via wi-fi (ip might not exist, but should be valid one), turn off wi-fi and enjoy the crash

events.js:141
      throw er; // Unhandled 'error' event
            ^
Error: connect ENETUNREACH 10.10.100.80:6998 - Local (0.0.0.0:53496)
    at Object.exports._errnoException (util.js:846:11)
    at exports._exceptionWithHostPort (util.js:869:20)
    at connect (net.js:834:14)
    at lookupAndConnect (net.js:927:5)
    at Socket.connect (net.js:896:5)
    at Object.exports.connect.exports.createConnection (net.js:61:35)
    at Connector.connect (/Users/vitaly/projects/mservice-utils/node_modules/arklogger/node_modules/ioredis/lib/connectors/connector.js:28:34)
    at Redis.<anonymous> (/Users/vitaly/projects/mservice-utils/node_modules/arklogger/node_modules/ioredis/lib/redis.js:228:20)
    at tryCatcher (/Users/vitaly/projects/mservice-utils/node_modules/arklogger/node_modules/ioredis/node_modules/bluebird/js/main/util.js:24:31)
    at Promise._resolveFromResolver (/Users/vitaly/projects/mservice-utils/node_modules/arklogger/node_modules/ioredis/node_modules/bluebird/js/main/promise.js:427:31)
    at new Promise (/Users/vitaly/projects/mservice-utils/node_modules/arklogger/node_modules/ioredis/node_modules/bluebird/js/main/promise.js:53:37)
    at Redis.connect (/Users/vitaly/projects/mservice-utils/node_modules/arklogger/node_modules/ioredis/lib/redis.js:214:10)
    at null._onTimeout (/Users/vitaly/projects/mservice-utils/node_modules/arklogger/node_modules/ioredis/lib/redis/event_handler.js:76:12)
    at Timer.listOnTimeout (timers.js:89:15)
@luin
Copy link
Collaborator

luin commented Jun 25, 2015

Seems to be a connection error. When a connection error happens, ioredis would emit error when there's at lease one listener. If there's none of listener listen to the error event, ioredis would just ignore the error and close the connection(and reconnect if retryStrategy is set).

@AVVS
Copy link
Collaborator Author

AVVS commented Jun 28, 2015

https://github.com/luin/ioredis/blob/master/lib/connectors/connector.js#L28 - this needs to be patched,
error can be triggered when network device goes down, which should trigger reconnect, not crash. I'll do something raw quickly

@AVVS
Copy link
Collaborator Author

AVVS commented Jun 28, 2015

Basically problem is that error happens before you init error listener, because callback is async.

  1. stream init
  2. nextTick
  3. error
  4. never gets to .once('error')
    this.connector.connect(function (err, stream) {
      if (err) {
        _this.flushQueue(err);
        reject(err);
        return;
      }

      _this.stream = stream;

      stream.once('connect', eventHandler.connectHandler(_this));
      stream.once('error', eventHandler.errorHandler(_this));
      stream.once('close', eventHandler.closeHandler(_this));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants