Getting errors while executing lambda function using couchbase / ottoman node-js sdk

424 Views Asked by At

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.

0

There are 0 best solutions below