Hi Everyone,
I have a .net console application packaged into a docker image and I am running it on a lambda.
I am getting this error after all the funtionality was executed. (Program.Main() functionality).
{
"errorType": "Runtime.ExitError",
"errorMessage": "RequestId: 1d4ca16a-2184-4945-ac66-d681ff54042b Error: Runtime exited without providing a reason"
}
My app uses playwright to generate pdf for a given url and then pushes the pdf into an s3 bucket. All of this is happening, but I am still getting the following error:-
INIT_REPORT Init Duration: 1638.79 ms Phase: invoke Status: error Error Type: Runtime.ExitError
START RequestId: 1d4ca16a-2184-4945-ac66-d681ff54042b Version: $LATEST
RequestId: 1d4ca16a-2184-4945-ac66-d681ff54042b Error: Runtime exited without providing a reason
Runtime.ExitError
END RequestId: 1d4ca16a-2184-4945-ac66-d681ff54042b
REPORT RequestId: 1d4ca16a-2184-4945-ac66-d681ff54042b Duration: 1640.79 ms Billed Duration: 1641 ms Memory Size: 2000 MB Max Memory Used: 126 MB
using Amazon;
using Amazon.S3;
using Amazon.S3.Model;
using Microsoft.Playwright;
using System;
using System.IO;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
// Set up unhandled exception handler
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
// Log the exception
Exception ex = (Exception)e.ExceptionObject;
Console.WriteLine($"Unhandled Exception: {ex}");
};
try
{
Console.WriteLine("GeneratePDF is done");
}
catch (Exception ex)
{
Console.WriteLine($"Exception in Main {ex.Message}");
}
finally
{
Console.WriteLine("Main function finally is executed.");
Environment.Exit(0);
}
}
}
Here is the docker file:-
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
WORKDIR /App
Copy everything
COPY . ./
Restore as distinct layers
RUN dotnet restore
Build and publish a release
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/sdk:7.0-jammy as base
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN mkdir /ms-playwright &&
mkdir /ms-playwright-agent &&
cd /ms-playwright-agent &&
dotnet new console &&
echo '<?xml version="1.0" encoding="utf-8"?><configuration><packageSources><add key="local" value="/tmp/"/></packageSources></configuration>' > nuget.config &&
dotnet add package Microsoft.Playwright &&
dotnet add package AWSSDK.S3 &&
dotnet build &&
./bin/Debug/net7.0/playwright.ps1 install --with-deps &&
rm -rf /var/lib/apt/lists/* &&
rm -rf /tmp/* &&
rm -rf /ms-playwright-agent &&
chmod -R 777 /ms-playwright
Build runtime image
FROM base as final
WORKDIR /App
COPY --from=build-env /App/out .
RUN chmod +x .playwright/node/*/node
ENTRYPOINT ["dotnet", "PWrightHtmlToPDF.dll"]