frank06/riak-js — Issue #97: db.remove drastically broken
Author: secoif
Created: 2011-10-17 09:21:23+00:00
State: open

Perhaps this is a Riak 1.0 issue, but any call to `remove` will break any following call to `getAll` with a 500, and attempts to get `keys` will report that the item is still in the bucket D:

Gist Here: https://gist.github.com/1292272

Test:

```javascript
var db = require('riak-js').getClient({port: 8098, debug: true})

exports['can call remove then call getAll'] = function(test) {
var bucket = 'Bugs'
var key = 'KLM'
var object = {
"frustrating": true
}

db.save(bucket, key, {fleet: 111, country: 'NL'}, function(err, data, meta) {
test.ok(!err, 'save: ' + err)
db.remove(bucket, key, function(err){
test.ok(!err, 'remove: '+ err)
db.getAll(bucket, function(err, data){
test.ok(!err, 'getAll: ' + err)
test.equal(data.length, 0, 'data.length should be 0!')
test.done()
})
})

})
}
exports['can call remove and item will actually be removed'] = function(test) {
var bucket = 'airlines'
var key = 'KLM'
var object = {
frustrating: true
}
db.save(bucket, key, {fleet: 111, country: 'NL'}, function(err, data, meta) {
test.ok(!err, 'save: ' + err)
db.remove(bucket, key, function(err){
test.ok(!err, 'remove: '+ err)
db.keys(bucket, function(err, keys){
test.ok(!err, 'keys: ' + err)
test.equal(keys.length, 0, 'keys.length should be 0!')
test.done()
})
})
})
}
```

Output:

```text
chamb% nodeunit test/units/test_bug.js

test_bug.js
[riak-js] PUT /riak/Bugs/KLM
[riak-js] DELETE /riak/Bugs/KLM
[riak-js] POST /mapred
✖ can call remove then call getAll

Assertion Message: getAll: Error: HTTP error 500: {"lineno":466,"message":"SyntaxError: syntax error","source":"()"}
AssertionError: false == true
at Object.ok (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39)
at .../test/units/test_bug.js:16:14
at HttpClient. (.../node_modules/riak-js/lib/http_client.js:378:18)
at IncomingMessage. (.../node_modules/riak-js/lib/http_client.js:10:95)
at IncomingMessage.emit (events.js:81:20)
at HTTPParser.onMessageComplete (http.js:133:23)
at Socket.ondata (http.js:1231:22)
at Socket._onReadable (net.js:677:27)
at IOWatcher.onReadable [as callback] (net.js:177:10)

Assertion Message: data.length should be 0!
AssertionError: undefined == 0
at Object.equal (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39)
at .../test/units/test_bug.js:17:14
at HttpClient. (.../node_modules/riak-js/lib/http_client.js:378:18)
at IncomingMessage. (.../node_modules/riak-js/lib/http_client.js:10:95)
at IncomingMessage.emit (events.js:81:20)
at HTTPParser.onMessageComplete (http.js:133:23)
at Socket.ondata (http.js:1231:22)
at Socket._onReadable (net.js:677:27)
at IOWatcher.onReadable [as callback] (net.js:177:10)

[riak-js] PUT /riak/airlines/KLM
[riak-js] DELETE /riak/airlines/KLM
[riak-js] GET /riak/airlines?keys=true
✖ can call remove and item will actually be removed

Assertion Message: keys.length should be 0!
AssertionError: 1 == 0
at Object.equal (/usr/local/lib/node_modules/nodeunit/lib/types.js:83:39)
at .../test/units/test_bug.js:36:14
at .../node_modules/riak-js/lib/http_client.js:98:18
at HttpClient. (.../node_modules/riak-js/lib/http_client.js:378:18)
at IncomingMessage. (.../node_modules/riak-js/lib/http_client.js:10:95)
at IncomingMessage.emit (events.js:81:20)
at HTTPParser.onMessageComplete (http.js:133:23)
at Socket.ondata (http.js:1231:22)
at Socket._onReadable (net.js:677:27)
at IOWatcher.onReadable [as callback] (net.js:177:10)

FAILURES: 3/8 assertions failed (51ms)
```