0
node: ../src/node_http_parser.cc:387: static v8::Handle<v8::Value>
node::Parser::Execute(const v8::Arguments&): Assertion `!current_buffer' failed.

This is the exact error I'm getting when I try to execute the following code as part of my Node server:

function fetchItem(idSection, queryURL){

    var item = {};

    // forced sync
    var readyToContinue = false;

    // execute query
    var options = {
        url:  queryURL,
        timeout: 2000
    }
    var request = require('request');
    request(options, function (error, response, body) {
        if (error){
            console.log('[ERROR] Request error: ', error);
            // release control
            readyToContinue = true;
        }
        else {
            // extract data from response body
            var response = JSON.parse(body).response;
            if (response.numFound > 0){
                var doc = response.docs[0];

                // create item object and store it
                item.name = doc.name;
                item.link = doc.link;
                item.image_link = doc.thumb_s;
            }
            // release control
            readyToContinue = true;
        }
    });
    // hold execution until readyToContinue
    while(!readyToContinue) {
        require('deasync').runLoopOnce();
    }
    return item;
}

The annoying/confusing part is that the request works fine when running locally on my machine, but the app crashes when I run it on one of our dev servers. Very grateful for any help on this.

NOTE: I force synchronised behaviour because I need multiple queries to execute in sequence - I appreciate that a number of replies are likely to be chastising me for not executing asynchronously...

1 Answer 1

1

Erm, it turns out the problem was something I should have checked earlier... The versions of Node running on my machine and the dev server were different. I just needed to update dev server.

I found a quick way of upgrading Node to the latest stable version on the command line:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Source: https://davidwalsh.name/upgrade-nodejs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.