aws-samples / aws-samples/serverless-dotnet-demo

.NET 8 Minimal API, AOT hangs

Open
#32 2 comments 0 reactions 1 assignee Claimed by @jeastham1993 View on GitHub
Dominant language
C#
Stars
162
Forks
42
PR merge metrics
No merged PRs in 30d

Description

Hi

I'm playing around with .NET 8 minimal API on lambda. Trying to adapt it to my current project. Copied NET8MinimalAPI from here, modified it slightly, and deployed it. But it hangs. Actually, I don't think it freezes, but my guess is that it reaches app.Run(), and then it's not registering any request or something. I can Console.Write just fine. I haven't used AWS in some time, so I'm no expert. It fails with:

```
{
"errorMessage": "2023-07-21T12:46:56.237Z 59070d7f-b7ec-46bd-a705-58517192eadf Task timed out after 3.06 seconds"
}
```
This is what I'm seeing in the logs (no errors):

```
START RequestId: 59070d7f-b7ec-46bd-a705-58517192eadf Version: $LATEST
2023-07-21T12:46:56.237Z 59070d7f-b7ec-46bd-a705-58517192eadf Task timed out after 3.06 seconds

END RequestId: 59070d7f-b7ec-46bd-a705-58517192eadf
REPORT RequestId: 59070d7f-b7ec-46bd-a705-58517192eadf Duration: 3059.06 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 49 MB
```

Testing using apigateway-aws-proxy testing template in Lambda.

Any idea what could be the issue?

Incidentally, to build it on Windows, I used this Dockerfile:

```
FROM public.ecr.aws/amazonlinux/amazonlinux:2 AS build-env

# Install necessary dependencies
RUN yum install -y clang gcc zlib zlib-devel krb5-devel openldap-devel openssl-devel cyrus-sasl-devel curl tar libicu

WORKDIR /app

# Copy everything and respect .dockerignore
COPY . ./

# Download .NET 8 Preview SDK tarball
RUN curl -L -o dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/0ce806be-89f7-4264-ad1b-6ff1887e7b6b/08a75d03919470fba420b970a7565ef5/dotnet-sdk-8.0.100-preview.6.23330.14-linux-x64.tar.gz

# Extract tarball
RUN mkdir -p dotnet && tar -xvf dotnet.tar.gz -C dotnet

# Build the project
RUN ./dotnet/dotnet publish -c Release -r linux-x64 -o /out ./testproj/testproj.csproj
```

In an attempt to solve this, I'm noticing that apigateway-aws-proxy is in camel case. Shouldn't ApiSerializerContext be decorated with [JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)] ? I can't understand that it would work without it. Anyways, adding it had no effect either.

Kind regards, Emil

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.