rethinkdbdash
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -80,3 +80,9 @@ var net = require('net'); | ||
protocolBuffer.writeUInt32LE(protodef.VersionDummy.Protocol.JSON, 0) | ||
self.connection.write(Buffer.concat([initBuffer, lengthBuffer, authBuffer, protocolBuffer])); | ||
helper.tryCatch(function() { | ||
self.connection.write(Buffer.concat([initBuffer, lengthBuffer, authBuffer, protocolBuffer])); | ||
}, function(err) { | ||
// The TCP connection is open, but the ReQL connection wasn't established. | ||
// We can just abort the whole thing | ||
self.connection.emit('error', err); | ||
}); | ||
}); | ||
@@ -489,3 +495,9 @@ self.connection.once('error', function(error) { | ||
// This will emit an error if the connection is closed | ||
self.connection.write(buffer); | ||
helper.tryCatch(function() { | ||
self.connection.write(buffer); | ||
}, function(err) { | ||
self.metadata[token].reject(err); | ||
delete self.metadata[token] | ||
}); | ||
}; | ||
@@ -492,0 +504,0 @@ |
@@ -153,1 +153,10 @@ var protodef = require(__dirname+'/protodef.js'); | ||
} | ||
module.exports.tryCatch = function tryCatch(toTry, handleError) { | ||
try{ | ||
toTry() | ||
} | ||
catch(err) { | ||
handleError(err) | ||
} | ||
} |
@@ -217,7 +217,5 @@ var Promise = require('bluebird'); | ||
connection.close().then(function() { | ||
//self._decreaseNumConnections(); | ||
self._expandBuffer(); | ||
}).error(function(e) { | ||
// We failed to close this connection, but we removed it from the pool... so err, let's just ignore that. | ||
//self._decreaseNumConnections(); | ||
self._expandBuffer(); | ||
@@ -240,3 +238,3 @@ }); | ||
self._decreaseNumConnections(); | ||
//self._expandBuffer(); | ||
self._expandBuffer(); | ||
}); | ||
@@ -243,0 +241,0 @@ connection.on('timeout', function() { |
{ | ||
"name": "rethinkdbdash", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "A Node.js driver for RethinkDB with promises and a connection pool", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
839708
23930