Does this only happen in this case? Yes only when the PDF tron library is used. If I remove PDFtron library the Lambda runs fine.
What if run the lambda normally? Lambda runs normally with Node js and core libraries like express or fs but fails with this error when PDFTron library is used
What if you run one of our nodejs samples locally? I will try this and let you know, but I am trying to use PDFTron for AWS Lambda project build through SAM and executed locally on the docker Linux x86-64 container
We have many customers using our SDK in AWS Lambda’s. So it appears that somehow in this setup the libPDFNetC.so library is either not being found at all, or its blocked somehow.
Please check the documenation for AWS SAM NodeJS on how to allow the runtime to load/read a native shared library .so file. Depending on the exact framework sometimes they need to be placed in a certain file, or registered in a config file of some sort.
Another possiblity is mixed up nodejs versions. If your lambda is Nodejs16 make sure that is how you are packaging it locally before deployment.
Thanks for the tip! I recently worked on a similar CMS-based project https://andersenlab.com/services/cms-based-development , and I found some great info on this topic . I ran into a similar problem in AWS SAM NodeJS. In my case, the problem was that the libPDFNetC.so library wasn’t in the expected path within the container.
Here’s what I did to fix it:
I added the .so library to the /var/task folder inside the AWS SAM container.
I made sure that the version of Node.js used locally matched the version specified in Lambda (in my case it was Node.js 16).
I also made sure all the dependencies were installed and built using sam build.