0

I am getting "Process exited before completing request" while executing lambda function.

When I check the logs in cloud watch it shows the error which says

"Cannot perform operation on a shutdown bucket." or sometimes it says

{ "errorMessage": "Client-Side timeout exceeded for operation. Inspect network conditions or increase the timeout", 
"errorType": "CouchbaseError", 
"stackTrace": [] 
}

I am using the following npm packages to communicate with the database server : couchbase, ottoman.

Below is the exports.handler function:

exports.handler = function(event, context, callback) {
  function sendResponse(error, data) {
    ottoman.bucket.disconnect();
    console.log("error : ", error);
    console.log("data : ", data);
    callback(error, data);
  }
  console.log("17", event);
  if(event.id != undefined) {
    user.find({ _id: event.id }, function(error, result) { //this line generates the error
        if (error) {
            sendResponse(error, null);
        }
        console.log("22 : ", result);
    });
  }
});

Below is my database connection file:

var couchbase=require('couchbase');
var ottoman=require('ottoman');
var config = require("./config");

var myCluster = new couchbase.Cluster(config.couchbase.server);
module.exports.bucket = myCluster.openBucket(config.couchbase.bucket,function (error) {
  if(error) {
    console.log(error);
  }
  module.exports.bucket.operationTimeout=20000;
  module.exports.bucket.n1qlTimeout=100000;
  console.log("Successfully opened igt bucket");
  ottoman.bucket = module.exports.bucket; });

We also have alternate function for user.find() method like user.getById() but it gives the same error.

What might be causing this issue.

ajinkya udgirkar
  • 223
  • 1
  • 10
  • show me your code sample – Abdul Manaf Sep 01 '16 at 14:34
  • @abdul have updated the above post with sample code. – ajinkya udgirkar Sep 01 '16 at 15:00
  • You are using both the `callback` method for NodeJS 4.3+ and the older `context.succeed` method. Remove the `context.succeed` method completely. Also, are you allocating enough time to the Lambda function? – Mark B Sep 01 '16 at 20:50
  • Have removed the older context.succeed() method & allocated time to the lambda function is set to 10 seconds but every time it completes execution within 5-6 seconds or even before that. – ajinkya udgirkar Sep 02 '16 at 07:57
  • @ajinkyaudgirkar did you ever find solution to this problem ? I am facing the same issue – dhaval Jun 29 '17 at 11:31
  • @dhaval setting operationTimeout & n1qlTimeout to "100000" worked but I don't think it is the right solution to this. As I think if we set the operation timeout to a large number it does not close the connection after query is executed which can cause memory leaks and can start adding dumps on your server which would in turn start taking up space and would fill your HDD in no time. You can give it a try and let me know your feedback. Cheers! :) – ajinkya udgirkar Jun 29 '17 at 12:16
  • Hey @ajinkyaudgirkar , somewhat unrelated question to this: how did you get couchnode to work on lambdas without libcouchbase ? Did you package everything together ? How did you do that ? – Andreas Klintberg Dec 06 '17 at 22:41
  • Hi @AndreasKlintberg, lambda needs the "node_modules" folder to be packaged along with your code. So, it will already have all the required dependencies for the function. – ajinkya udgirkar Dec 07 '17 at 06:39
  • Many thanks for answering, really appreciate it! Yeah, I just didn't find anything explaining how to do it. Using https://aws.amazon.com/blogs/compute/nodejs-packages-in-lambda/ but instead of opencv libcouchbase. If successful I'll put a blogpost for it. – Andreas Klintberg Dec 07 '17 at 23:43
  • The problem was that I built couchbase-node package on my mac, tried to upload it all to lambda, but it failed. I had to create a AWS EC2 instance using AWS Linux, build/npm install the couchbase node package there and then download it (since it needs to be node-gyp compiled on the AWS linux not mac os to run in a a lambda. – Andreas Klintberg Apr 06 '18 at 13:30

0 Answers0