christkv/node-mongodb-native — Issue #414: Buffer OOB in 0.9.7.1-dev
Author: novemberborn
Created: 2011-11-23 14:05:20+00:00
State: open

Running the test script below. It gets stuck at "querying all users" for a while and then crashes with this error:

```
buffer.js:374
if (end > this.length) throw new Error('oob');
^
Error: oob
at Buffer.slice (buffer.js:374:32)
at Socket. (…/node_modules/mongodb/lib/mongodb/connection/connection.js:253:41)
at Socket.emit (events.js:64:17)
at Socket._onReadable (net.js:678:14)
at IOWatcher.onReadable [as callback] (net.js:177:10)
```

```js
var mongodb = require("mongodb");

var options = {
auto_reconnect: true,
poolSize: 4,
socketOptions: { keepAlive: 100 }
};
var replSet = new mongodb.ReplSetServers([
new mongodb.Server("mongo-1", 27017, options),
new mongodb.Server("mongo-2", 27017, options),
new mongodb.Server("mongo-3", 27017, options)
]);
var db = new mongodb.Db("data", replSet);
db.open(function(err, client){
client.collection("users", function(users){
console.log("Connected");
db.users = users;
query();
});
});

function query(){
console.log("[%s] querying all users", new Date);
setTimeout(query, 70 * 60 * 1000);
db.users.find().count(function(err, all){
if(err){
console.log("[%s] %s", new Date, err.stack || err);
}else{
console.log("[%s] found %s users", new Date, all);
}
});
}
```