aws-lambda-dotnet icon indicating copy to clipboard operation
aws-lambda-dotnet copied to clipboard

SnapStart: Using AddAWSLambdaBeforeSnapshotRequest() and AddHttpContextAccessor() in-conjunction causes initialization failure

Open budgetdevv opened this issue 7 months ago • 4 comments

Describe the bug

As described above. See: https://github.com/budgetdevv/AWSSnapStartBugRepro/blob/5833e924110e59d3cc574461ecf2023802a0d1dd/SnapStartBugTest/src/SnapStartBugTest/Program.cs#L14C10-L14C32

Regression Issue

  • [ ] Select this option if this issue appears to be a regression.

Expected Behavior

It should be able to initialize.

Current Behavior

It fails to initialize with an exception.

Reproduction Steps

  • Deploy the repo @ https://github.com/budgetdevv/AWSSnapStartBugRepro into an AWS Lambda instance
  • Enable SnapStart
  • Publish a version to trigger SnapStart's snapshotting

Possible Solution

Currently I am using a custom HttpContextAccessor to circumvent this

Additional Information/Context

Do look into the stacktrace here: https://gist.github.com/budgetdevv/b1304220f2cf3921723109a53f9a82a0#file-gistfile1-txt-L32

AWS .NET SDK and/or Package version used

Targeted .NET Platform

.NET 8

Operating System and version

OSX Sonoma

budgetdevv avatar May 09 '25 17:05 budgetdevv

Investigating

ppittle avatar May 12 '25 18:05 ppittle

Was able to reproduce this issue, but needed to change this line to use LambdaEventSource.RestApi.

With that, and #2071, the Lambda deploys and functions correctly.

ppittle avatar May 13 '25 22:05 ppittle

Was able to reproduce this issue, but needed to change this line to use LambdaEventSource.RestApi.

With that, and #2071, the Lambda deploys and functions correctly.

I believe it is because I am using a function URL

budgetdevv avatar May 15 '25 11:05 budgetdevv

Fix has been released and is available in Amazon.Lambda.AspNetCoreServer 9.1.1 and Amazon.Lambda.AspNetCoreServer.Hosting 1.8.1

ppittle avatar May 19 '25 16:05 ppittle

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Aug 25 '25 20:08 github-actions[bot]