aws-lambda-dotnet
aws-lambda-dotnet copied to clipboard
Timeout doesn't seem to be respected
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)
Hi @TommyN,
Good afternoon.
Thanks for reporting the issue. Please share the sample code to help reproduce the issue ay our end.
Regards, Ashish
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.
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.
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.
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.