aws-samples / serverless-dotnet-demo

MIT No Attribution
140 stars 37 forks source link

.NET 8 Minimal API, AOT hangs #32

Open emilmuller opened 1 year ago

emilmuller commented 1 year ago

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

jeastham1993 commented 12 months ago

@emilmuller apologies for the delayed response. Now that RC1 of .NET 8 is available I'm going to revisit some of these samples, hopefully over the weekend. I'll reply to this thread when they are re-deployed and working.

jeastham1993 commented 10 months ago

@emilmuller could you try the .NET 8 examples again now? I've just updated them.