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

Timeout doesn't seem to be respected

Open TommyN opened this issue 2 years ago • 3 comments

Describe the bug

We have a net6.0 Lambda function (512MB Memory) with a timeout set to 2 seconds. For some reason the timeout value doesn't seem to be respected:


@message
Task timed out after 2.53 seconds
Task timed out after 4.00 seconds
Task timed out after 2.54 seconds
Task timed out after 4.00 seconds
Task timed out after 2.54 seconds
Task timed out after 4.00 seconds
Task timed out after 2.52 seconds
Task timed out after 4.00 seconds
Task timed out after 2.54 seconds
Task timed out after 4.00 seconds
Task timed out after 2.53 seconds
Task timed out after 4.00 seconds
Task timed out after 2.53 seconds
Task timed out after 4.00 seconds
Task timed out after 2.58 seconds
Task timed out after 4.00 seconds

Expected Behavior

I expected the function to time out after 2 seconds

Current Behavior

Function times out after 4 seconds. Billing is limited to 2 seconds.

Duration: 4003.89 ms Billed Duration: 2000 ms Memory Size: 512 MB Max Memory Used: 512 MB

Reproduction Steps

N/A

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Amazon.Lambda.Core Version="1.1.0"

Targeted .NET Platform

NET 6

Operating System and version

.NET 6 (C#/PowerShell)

TommyN avatar Apr 28 '22 07:04 TommyN

Hi @TommyN,

Good afternoon.

Thanks for reporting the issue. Please share the sample code to help reproduce the issue ay our end.

Regards, Ashish

ashishdhingra avatar Apr 29 '22 20:04 ashishdhingra

This happened 16 times over the last 4 days. The Lambda function was invoked 25M times, so I don't have a sample that will easily provoke the issue.

image

TommyN avatar May 02 '22 06:05 TommyN

You may wish to consder var cts = new CancellationTokenSource(TimeSpan.FromSeconds(2)); and then passing cts.Token into your async methods to get a more precise timeout.

ryanwilliams83 avatar Nov 01 '23 03:11 ryanwilliams83

I'm gonna close this ticket because it is pretty old and probably not actionable anymore. Lambda has changed quite a bit since this issue first reported but I wonder if the original issue was the 4 second timeouts where the cold starts and I don't think the init part counts towards the timeout.

normj avatar Mar 29 '24 23:03 normj

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 Mar 29 '24 23:03 github-actions[bot]