Skip to content
This repository has been archived by the owner on Feb 22, 2019. It is now read-only.

No hosts available causes uncaught exception #71

Closed
calvinfo opened this issue Sep 20, 2012 · 0 comments · Fixed by #72
Closed

No hosts available causes uncaught exception #71

calvinfo opened this issue Sep 20, 2012 · 0 comments · Fixed by #72

Comments

@calvinfo
Copy link
Contributor

I have an app where I'd like to maintain availability even when I can't connect to my cassandra cluster. The rest of the app can try to make requests to the DB, and on a failure I can just put messages in a queue to be processed later.

Currently when there are no hosts available, the pool will emit an error but then proceed to throw an uncaught exception caused by accessing a property of an undefined var.

From the Pool connection code:

Pool.prototype.getConnection = function(){
  var len = this.clients.length,
      rnd = Math.floor(Math.random() * len),
      host = this.clients[rnd];

  if (!host){
    this.emit('error', new Error('No Available Connections'));
  }

  if (host.ready){  // causes exception!!
    return host;
  } else {
  ...
}

I'd like to convert this to look more like the other query functions where if the database is unavailable for any reason, I will get an unavailable exception on querying. My app can then choose whether to re-connect in the pool and how to handle the failure.

Anything I'm missing here?

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

Successfully merging a pull request may close this issue.

2 participants