NodeJS couchbase@2.0.0-beta error with view query

Hi,

Im trying to execute a query using couchbase@2.0.0-beta for NODEJS and the server is 3.0 beta. The follow error occurs whatever view query I try:

Floating point exception: 8

No stacktraces whatsoever, no more information, nothing!

The query invocation is quite simple:

bucketConnection.query(ViewQuery.from('design', 'name').key('myKey'), function(err, result){});

How can I debug this?

Thanks.

Having the same issue. Have you figured this out at all?

1 Answer

« Back to question.

We quit nodejs and got back to java, not 'cause of this issue but 'cause of node itself.
Couldn't figure that out this error though.

Well, since the system seems to eat my answer...

This is fixed by making sure node has a connection to couchbase before querying.

i have filed a bug report, and a fix should be made in the next few releases.

For now, i have used the following code to fix the issue: (basically, just check the connected variable on a set timeout loop and when true make the call)

var couchbase = require('couchbase');
var connected = false;
 
function Couchbase(conf) {
    var cluster = new couchbase.Cluster('couchbase://' + conf.ip);
    this.db = cluster.openBucket(conf.bucket, function (err) {
        if (err) {
            // Failed to make a connection to the Couchbase cluster.
            throw err;
        }
        connected = true;
    });
    this.db.setTranscoder(
        function (value) {
            return {
                value: new Buffer(JSON.stringify(value), 'utf8'),
                flags: 0
            };
        },
        function (doc) {
            return JSON.parse(doc.value.toString('utf8'));
        }
    );
 
    this.query = couchbase.ViewQuery;
}
 
Couchbase.prototype = {
    get: function ($design, $view, $limit) {
        var app = this;
        //make sure the DB is connected before querying.
        var retry = function () {
            if (!connected) {
                setTimeout(retry, 200);
            } else {
                app._get($design, $view);
            }
        };
        retry();
    },
    _get: function ($design, $view, $limit) {
        console.log('running query');
        var query = this.query.from($design, $view).limit($limit);
        this.db.query(query, function (ret) {
            console.log('results');
            console.log(ret);
            for (i in ret) {
                console.log(ret[i]);
            }
        })
    }
};
 
exports.Couchbase = Couchbase;

annd since i can't edit my post, the _get function should be the following... The documentation uses just ret, but in reality, it is err, rows, meta.

_get: function(){
        var query = this.query.from('server', 'by_id').limit(10);
        this.db.query(query, function (err, rows, meta) {
            for (i in rows) {
                console.log(rows[i]);
            }
        })
    }