Skip to content

Redis error #23

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

Open
wants to merge 3 commits into
base: 0.9.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion lib/database/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,26 @@ Connection.prototype.connect = function(cb) {
redis.createClient(config.port, config.host, config.options).auth(config.password) :
redis.createClient(config.port, config.host, config.options);

client.once('ready', function() {
if (config.options.onError) {
client.on('error', function connectionErrorListener(){
var args = Array.prototype.slice.call(arguments);
args.push(client);
config.options.onError.apply(this, args);
});
}

var event = 'ready';
if (config.options.no_ready_check) {
event = 'connect';
}

//cant share the listener below as thats tied with waterline business
if (config.options.onReady) {
client.on(event, config.options.onReady);
}

//make the client listen on on rather than once, a reconnect happens it needs to run the cb
client.once(event, function() {
cb(null, client);
});
};