Couchbase throws an error when Nodejs 8.10 AWS Lambda function is invoked

I am using Docker Engine 18.0.09.1 with the Serverless CLI to package and deploy AWS Lambda CRUD functions. The deployment succeeds in uploading the necessary modules, creates all the Lambda functions, and builds out the CloudFormation. I verified all the node_modules installed within the Docker /lambda-project directory are present in the S3 directory to which the deployment was directed.

Unfortunately, when I test the create function, or any function, I receive this error:

“/var/lang/bin/…/lib/libstdc++.so.6: version `GLIBCXX_3.4.21’ not found (required by /var/task/node_modules/couchbase/build/Release/couchbase_impl.node)”

This is an amazonlinux Docker image. I have tried all the usual junk to install from sudo apt-get, yum install, etc, none of those are recognized. I am at a loss.

Any help is appreciated.

1 Like

Hello,
I’m answering now (a bit late…) as I had the same issue recently and did not find any answer.

The problem is that lambda environment does not have the right version of this lib.

What you need is to get a latest version of this lib (on amazonlinux2, I did a yum update libstdc++ and copied it from /usr/lib64).
You then need to create a lib folder at the root of your code and place it there (I use the zip functionality directly within lambda, not serverless cli).
Any library not found by lambda will be searched there!

And magically, it works !

1 Like

I am facing same issue. In my /usr/lib64. I could find two files ’ libstdc++.so.6.0.24’ and ‘libstdc++.so.6’. I have copy this two file in my project my-service/lib/{copy this two files}.

bash-4.2# serverless invoke -f hello
{
“errorMessage”: “/var/lang/bin/…/lib/libstdc++.so.6: version `GLIBCXX_3.4.21’ not found (required by /var/task/node_modules/couchbase/build/Release/couchbase_impl.node)”,
“errorType”: “Error”,
“stackTrace”: [
“Module.load (module.js:565:32)”,
“tryModuleLoad (module.js:505:12)”,
“Function.Module._load (module.js:497:3)”,
“Module.require (module.js:596:17)”,
“require (internal/module.js:11:18)”,
“bindings (/var/task/node_modules/bindings/bindings.js:84:48)”,
“Object. (/var/task/node_modules/couchbase/lib/binding.js:213:36)”,
“Module._compile (module.js:652:30)”,
“Object.Module._extensions…js (module.js:663:10)”
]
}

I’m not sure if serverless cli works the same, but I expect it should.
I did also copy those 2 files ti my-service/lib , plus the one called libstdc++.so
On which linux are you ? amazonlinux ? amazonlinux2 ? It should be amazonlinux I think.

I personaly went through different steps, starting from an amazon linux container. But I thought the relevant step was the one I mentioned here. If you wish, I can give you the detailed steps I followed, and you can try that (I did not have time to figure out yet which steps were absolutely necessary and which weren’t).

Thank you KarTookki.

I have follow steps mentioned in Fix GLIBCXX Errors From Serverless Framework And AWS Lambda link to resolve my profile. However, would not succeeded in it.

I will appreciate if you can give me any steps / clue to resolve issue.

Hi, sorry for the delay, I did not see your reply.

Here are all the steps I took from a linux ec2. Some of those steps might be redundant, I hadn’t had time to filter out.
Please try this from your lambda directory and let me know if you can compile:

docker pull amazonlinux
docker run -v $(pwd):/lambda-project -it amazonlinux
cd lambda-project
yum install gcc
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
. ~/.nvm/nvm.sh
yum update
yum install tar
yum install gzip
nvm install 8.10

yum install wget
wget http://packages.couchbase.com/releases/couchbase-release/couchbase-release-1.0-4-x86_64.rpm
rpm -iv couchbase-release-1.0-4-x86_64.rpm
yum install libcouchbase-devel libcouchbase2-bin gcc gcc-c++
yum install libstdc
rm rpm…

copy libstcdc* from /usr/lib64 to our lambda /lib directoty
npm install couchbase --save
npm install uuid --save
npm install joi --save
exit
exit

To know if it will compile, you can execute (first pull lambci/lambda:build-nodejs8.10) - otherwise zip the folder and deploy/execute the lambda :

docker run -v “$PWD”:/var/task lambci/lambda:build-nodejs8.10

Let me know if you have questions,