aerospike
Advanced tools
Comparing version 2.5.1 to 2.5.2
@@ -0,1 +1,13 @@ | ||
v2.5.2 / 2017-04-20 | ||
=================== | ||
v2.5.x is the last release to support Node.js v0.12 and io.js. The next major client release will require Node.js v4 or later. | ||
* **New Features** | ||
* Capture more useful stacktraces for debugging [#189](https://github.com/aerospike/aerospike-client-nodejs/issues/189) | ||
* **Bug Fixes** | ||
* Synchronous error callback in query command causes "unspecified" error in record stream [#146](https://github.com/aerospike/aerospike-client-nodejs/issues/146) | ||
* Query/scan record stream should emit AerospikeError instances [#187](https://github.com/aerospike/aerospike-client-nodejs/issues/187) | ||
v2.5.1 / 2017-04-11 | ||
@@ -10,4 +22,2 @@ =================== | ||
This is the last release to support Node.js v0.12 and io.js. The next client release will require Node.js v4 or later. | ||
* **New Features** | ||
@@ -14,0 +24,0 @@ * Support ns/set truncate command [#712](https://github.com/aerospike/aerospike-client-nodejs/issues/172) |
@@ -52,3 +52,3 @@ // ***************************************************************************** | ||
*/ | ||
function AerospikeError (code, message, func, file, line) { | ||
function AerospikeError (code, message, func, file, line, stack) { | ||
/** | ||
@@ -61,3 +61,3 @@ * Error name | ||
*/ | ||
this.name = 'AerospikeError' | ||
Object.defineProperty(this, 'name', {value: 'AerospikeError'}) | ||
@@ -111,7 +111,12 @@ /** | ||
Error.captureStackTrace(this, this.constructor) | ||
if (stack) { | ||
stack = stack.replace(/^.*$/m, util.format('%s: %s', this.name, this.message)) | ||
Object.defineProperty(this, 'stack', {value: stack}) | ||
} else { | ||
Error.captureStackTrace(this, this.constructor) | ||
} | ||
} | ||
AerospikeError.fromASError = function (err) { | ||
return new AerospikeError(err.code, err.message, err.func, err.file, err.line) | ||
return new AerospikeError(err.code, err.message, err.func, err.file, err.line, err.stack) | ||
} | ||
@@ -118,0 +123,0 @@ |
@@ -128,6 +128,3 @@ // ***************************************************************************** | ||
} | ||
var client = this.client | ||
client.as_client.jobInfo(this.jobID, this.module, policy, function jobInfoCb (err, info) { | ||
client.callbackHandler(callback, err, info) | ||
}) | ||
this.client.sendCommand('jobInfo', [this.jobID, this.module, policy], callback) | ||
} | ||
@@ -134,0 +131,0 @@ |
@@ -17,3 +17,2 @@ // ***************************************************************************** | ||
const as = require('../build/Release/aerospike.node') | ||
const Job = require('./job') | ||
@@ -312,6 +311,5 @@ const Key = require('./key') | ||
if (endCb) stream.on('end', endCb) | ||
var asClient = this.client.as_client | ||
var queryFn = this.udf ? asClient.queryForeach : asClient.queryAsync | ||
queryFn.call(asClient, this.ns, this.set, this, policy, function (error, record, meta, key) { | ||
if (error && error.code !== as.status.AEROSPIKE_OK) { | ||
var cmd = this.udf ? 'queryForeach' : 'queryAsync' | ||
var queryCb = function (error, record, meta, key) { | ||
if (error) { | ||
stream.emit('error', error) | ||
@@ -327,3 +325,4 @@ } else if (record === null) { | ||
return !stream.aborted | ||
}) | ||
} | ||
this.client.sendCommand(cmd, [this.ns, this.set, this, policy], queryCb) | ||
return stream | ||
@@ -354,4 +353,2 @@ } | ||
udfArgs = null | ||
} else if (typeof callback !== 'function') { | ||
throw new TypeError('"callback" argument must be a function') | ||
} | ||
@@ -363,6 +360,3 @@ this.udf = { | ||
} | ||
var client = this.client | ||
client.as_client.queryApply(this.ns, this.set, this, policy, function (error, result) { | ||
client.callbackHandler(callback, error, result) | ||
}) | ||
this.client.sendCommand('queryApply', [this.ns, this.set, this, policy], callback) | ||
} | ||
@@ -398,4 +392,2 @@ | ||
queryID = null | ||
} else if (typeof callback !== 'function') { | ||
throw new TypeError('"callback" argument must be a function') | ||
} | ||
@@ -409,6 +401,6 @@ this.udf = { | ||
var self = this | ||
this.client.as_client.queryBackground(this.ns, this.set, this, policy, queryID, function queryBackgroundCb (err) { | ||
this.client.sendCommand('queryBackground', [this.ns, this.set, this, policy, queryID], function (err) { | ||
var module = self.filters.length > 0 ? 'query' : 'scan' | ||
var job = new Job(self.client, queryID, module) | ||
self.client.callbackHandler(callback, err, job) | ||
callback(err, job) | ||
}) | ||
@@ -415,0 +407,0 @@ } |
@@ -17,3 +17,2 @@ // ***************************************************************************** | ||
const as = require('../build/Release/aerospike.node') | ||
const Job = require('./job') | ||
@@ -220,6 +219,6 @@ const Key = require('./key') | ||
scanID = scanID || Job.safeRandomJobID() | ||
var client = this.client | ||
client.as_client.scanBackground(this.ns, this.set, this, policy, scanID, function scanBackgroundCb (err) { | ||
var job = new Job(client, scanID, 'scan') | ||
client.callbackHandler(callback, err, job) | ||
var self = this | ||
this.client.sendCommand('scanBackground', [this.ns, this.set, this, policy, scanID], function (err) { | ||
var job = new Job(self.client, scanID, 'scan') | ||
callback(err, job) | ||
}) | ||
@@ -246,4 +245,4 @@ } | ||
var scanID = Job.safeRandomJobID() | ||
this.client.as_client.scanAsync(this.ns, this.set, this, policy, scanID, function (error, record, meta, key) { | ||
if (error && error.code !== as.status.AEROSPIKE_OK) { | ||
var scanCb = function (error, record, meta, key) { | ||
if (error) { | ||
stream.emit('error', error) | ||
@@ -253,7 +252,10 @@ } else if (record === null) { | ||
} else { | ||
key = new Key(key.ns, key.set, key.key, key.digest) | ||
if (key) { | ||
key = new Key(key.ns, key.set, key.key, key.digest) | ||
} | ||
stream.emit('data', record, meta, key) | ||
} | ||
return !stream.aborted | ||
}) | ||
} | ||
this.client.sendCommand('scanAsync', [this.ns, this.set, this, policy, scanID], scanCb) | ||
stream.job = new Job(this.client, scanID, 'scan') | ||
@@ -260,0 +262,0 @@ return stream |
{ | ||
"name": "aerospike", | ||
"version": "2.5.1", | ||
"version": "2.5.2", | ||
"description": "Aerospike Client Library", | ||
@@ -5,0 +5,0 @@ "tags": [ |
@@ -22,2 +22,3 @@ // ***************************************************************************** | ||
const helper = require('./test_helper') | ||
const keygen = helper.keygen | ||
const extend = require('util')._extend | ||
@@ -81,2 +82,70 @@ | ||
}) | ||
context('callbacks', function () { | ||
it('should raise an error when calling a command without passing a callback function', function () { | ||
expect(function () { helper.client.truncate('foo', 'bar') }).to.throwException(function (e) { | ||
expect(e).to.be.a(TypeError) | ||
expect(e.message).to.be('"callback" argument must be a function') | ||
}) | ||
}) | ||
// Execute a client command on a client instance that has been setup to | ||
// trigger an error; check that the error callback occurs asynchronously, | ||
// i.e. only after the command function has returned. | ||
// The get command is used for the test but the same behavior should apply | ||
// to all client commands. | ||
function assertErrorCbAsync (client, errorCb, done) { | ||
var checkpoints = [] | ||
var checkAssertions = function (checkpoint) { | ||
checkpoints.push(checkpoint) | ||
if (checkpoints.length !== 2) return | ||
expect(checkpoints).to.eql(['after', 'callback']) | ||
client.close(false) | ||
done() | ||
} | ||
var key = keygen.string(helper.namespace, helper.set)() | ||
client.get(key, function (err, _record) { | ||
errorCb(err) | ||
checkAssertions('callback') | ||
}) | ||
checkAssertions('after') | ||
} | ||
it('callback is asynchronous in case of an client error', function (done) { | ||
// trying to send a command to a client that is not connected will trigger a client error | ||
var client = Aerospike.client() | ||
var errorCheck = function (err) { | ||
expect(err).to.be.an(Error) | ||
expect(err.message).to.equal('Not connected.') | ||
} | ||
assertErrorCbAsync(client, errorCheck, done) | ||
}) | ||
it('callback is asynchronous in case of an I/O error', function (done) { | ||
// maxConnsPerNode = 0 will trigger an error in the C client when trying to send a command | ||
var config = extend({ maxConnsPerNode: 0 }, helper.config) | ||
Aerospike.connect(config, function (err, client) { | ||
if (err) throw err | ||
var errorCheck = function (err) { | ||
expect(err).to.be.an(Error) | ||
expect(err.code).to.equal(Aerospike.status.AEROSPIKE_ERR_NO_MORE_CONNECTIONS) | ||
} | ||
assertErrorCbAsync(client, errorCheck, done) | ||
}) | ||
}) | ||
}) | ||
describe('Client#captureStackTraces', function () { | ||
it('should capture stack traces that show the command being called', function (done) { | ||
var client = helper.client | ||
var key = keygen.string(helper.namespace, helper.set)() | ||
var orig = client.captureStackTraces | ||
client.captureStackTraces = true | ||
client.get(key, function (err) { | ||
expect(err.stack).to.match(/Client.get/) | ||
client.captureStackTraces = orig | ||
done() | ||
}) | ||
}) | ||
}) | ||
}) |
@@ -181,3 +181,2 @@ // ***************************************************************************** | ||
percent: 50, | ||
concurrent: true, | ||
nobins: true | ||
@@ -192,4 +191,5 @@ }) | ||
stream.on('end', function () { | ||
// FIXME: with percent < 100, scan oftern returns zero records - is this a problem?! | ||
expect(recordsReceived).to.be.within(0, numberOfRecords - 1) | ||
// The scan percentage is not very exact, esp. for small sets, so we | ||
// just test that the scan did not return every single record. | ||
expect(recordsReceived).to.be.lessThan(numberOfRecords) | ||
done() | ||
@@ -196,0 +196,0 @@ }) |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1234511
206
18843
78