Troubleshooting: Running the latest versions of QuestPDF on a .NET6 AWS Lambda Function - Banner

Introduction

I’m currently working on an API with the following specifications:

  • .NET (C#), dotnet6, x64;
  • Deployed to AWS Lambda functions (runtime: dotnet6).

The functional requirement of this project involves generating a PDF document. To achieve this, we used the QuestPDF library, which proved to be easy to understand and use.

Most of the time, our API used the versions 2023.12.4 to 2023.12.6 of the QuestPDF library without any issues :smiley:

But, considering the recent major improvements in the library, we decided to update it to the latest versions (2024.3.x). We knew that some breaking changes were introduced, so we did the update with caution.

Error

Unfortunately, after the update, the AWS Lambda function (runtime: dotnet6) stopped working. We tried multiple versions of the lib (from 2024.3.0 to 2024.3.10), we targeted the project to linux-x64, checked if the published packages contained all the required files, but the API still didn’t work.

The exception message indicated an error to load the libQuestPdfSkia shared library - but the mentioned file was there at the published lib folder:

Unable to load shared library ‘QuestPdfSkia’ or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libQuestPdfSkia: cannot open shared object file: No such file or directory

Troubleshooting

Engaging in discussion with Marcin, the author of QuestPDF suggested using the LD_DEBUG environment variable to troubleshoot the situation.

After setting the LD_DEBUG env var as all, finally we found the root cause:

/lib64/libm.so.6: error: version lookup error: version `GLIBC_2.27’ not found (required by /var/task/libQuestPdfSkia.so) (fatal)

The version 2.27 of glibc wasn’t found.

According to the AWS documentation, the dotnet6 AWS Lambda runtime is built on the AL2 image. The AL2 image supports glibc 2.26. Consequently, the AWS Lambda Function (dotnet6) cannot load and utilize the libQuestPdfSkia dependency.

AWS has upgraded the dotnet8 runtime to the AL2023 lambda image, which supports glibc 2.34.

AWS Lambda Images and Dependencies

What can we do?

Until the moment, there is no solution for having the latest versions of QuestPDF to run on AWS Lambda Function (runtime: dotnet6).

So, for those who already have migration plans to the new dotnet8 runtime, it might be an interesting approach. Otherwise, the downgrade to 2023.12.6 would be needed.

In case you would like to check if any updates happened to this discussion, please check it here.

References


If you found this helpful, I’d appreciate your feedback! :smiley:

Best regards!