limestone icon indicating copy to clipboard operation
limestone copied to clipboard

null data crashing

Open samjosephmark opened this issue 11 years ago • 0 comments

I have just updated to 0.1.4 using npm, using Node 0.10.13 and having the issue with both Sphinx 2.0.4 and now 2.0.8. I had been happily using 0.1.3 with Node 0.8.15 and Sphinx 2.0.4.

On performing a query I get the correct result back, however I then get a null response back shortly after.

This is my code snippet using async

async.waterfall([
    function(callback) { // connect to sphinx
        limestone.connect(config.sphinx.host + ":" + config.sphinx.port, callback);
    },
    function(callback) { // perform query
        limestone.query({
            query: params.keywords
          , maxmatches: params.limit
          , indexes: 'test1'
          , mode: 4 // Extended
        }, callback);
    },
    function(answer, callback) { // disconnect and convert results for output
        limestone.disconnect();
        util.log("Extended search for '" + params.keywords + "' yielded " +
        (answer ? answer.match_count: 0) + " results: ");
        if (!answer || !answer.match_count) return callback(null, []);

        var personIds = [];
        util.log('answer length:' + answer.matches.length);
        for (i = 0; i < answer.matches.length; i++) {
            personIds.push(answer.matches[i].doc);
        }
        util.log('personIds:' + personIds);
        orm.model('Person').getMappedPeople({
            personIds: personIds
          , canInvite: params.canInvite
          , order: 'lastName, firstName '
        }, callback);
    }
], next);

I also added a logging line on limestone.js at line 560 console.log('data:' + data); This is log output

data:[0,0,1,25,0,0,0,221,0,0,0,0,0,0,0,3,0,0,0,4,110,97,109,101,0,0,0,9,102,105,114,115,116,110,97,109,101,0,0,0,8,108,97,115,116,110,97,109,101,0,0,0,4,0,0,0,5,105,115,112,114,111,0,0,0,1,0,0,0,16,103,108,111,98,97,108,116,114,97,99,107,99,111,117,110,116,0,0,0,1,0,0,0,13,102,111,108,108,111,119,101,114,99,111,117,110,116,0,0,0,1,0,0,0,14,102,111,108,108,111,119,105,110,103,99,111,117,110,116,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,0,0,0,0,38,0,0,6,155,0,0,0,0,0,0,0,1,0,0,0,36,0,0,0,66,0,0,0,0,0,0,0,65,0,0,6,155,0,0,0,0,0,0,0,2,0,0,0,21,0,0,0,25,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0,4,97,108,101,120,0,0,0,2,0,0,0,2]
11 Jul 05:27:41 - Extended search for 'alex' yielded 2 results:
11 Jul 05:27:41 - answer length:2
11 Jul 05:27:41 - personIds:38,65
data:null

At the end you can see the data:null line which then crashes Node with the following error

home/ubuntu/releases/20130711011458/node_modules/limestone/limestone.js:591
var new_buffer = new Buffer(this.data.length + data.length);
^
TypeError: Cannot read property 'length' of null
at Object.response_output.append (/home/ubuntu/releases/20130711011458/node_modules/limestone/limestone.js:591$
at Socket.readResponseData (/home/ubuntu/releases/20130711011458/node_modules/limestone/limestone.js:563:26)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at Socket.Readable.read (_stream_readable.js:266:5)
at Socket.onSocketEnd (net.js:258:10)
at Socket.EventEmitter.emit (events.js:92:17)
at TCP.onread (net.js:552:10)

I have patched this locally by returning from the readResponseData() function if data is found to be null. Not completely sure what the impact of this is though.

samjosephmark avatar Jul 11 '13 05:07 samjosephmark