File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -650,7 +650,7 @@ internal struct LambdaHTTPServer {
650
650
" arn:aws:lambda:us-east-1: \( Int16 . random ( in: Int16 . min ... Int16 . max) ) :function:custom-runtime "
651
651
) ,
652
652
( AmazonHeaders . traceID, " Root= \( AmazonHeaders . generateXRayTraceID ( ) ) ;Sampled=1 " ) ,
653
- ( AmazonHeaders . deadline, " \( Duration . distantFuture . milliseconds ( ) ) " ) ,
653
+ ( AmazonHeaders . deadline, " \( Duration . maxLambdaExecutionTime . milliseconds ( ) ) " ) ,
654
654
] )
655
655
656
656
return LocalServerResponse (
Original file line number Diff line number Diff line change @@ -52,11 +52,20 @@ extension Duration {
52
52
return . milliseconds( Int64 ( ts. tv_sec) * 1000 + Int64( ts. tv_nsec) / 1_000_000 )
53
53
}
54
54
55
- /// Returns a Duration between Unix epoch and the distant future
55
+ /// Hardcoded maximum execution time for a Lambda function.
56
56
@usableFromInline
57
- static var distantFuture : Duration {
58
- // Use a very large value to represent the distant future
59
- millisSinceEpoch + Duration. seconds ( . greatestFiniteMagnitude)
57
+ static var maxLambdaExecutionTime : Duration {
58
+ // 15 minutes in milliseconds
59
+ // see https://docs.aws.amazon.com/lambda/latest/dg/configuration-timeout.html
60
+ . milliseconds( 15 * 60 * 1000 )
61
+ }
62
+
63
+ /// Returns the maximum deadline for a Lambda function execution.
64
+ /// This is the current time plus the maximum execution time.
65
+ /// This function is onwly used by the local server for testing purposes.
66
+ @usableFromInline
67
+ static var maxLambdaDeadline : Duration {
68
+ millisSinceEpoch + maxLambdaExecutionTime
60
69
}
61
70
62
71
/// Returns the Duration in milliseconds
You can’t perform that action at this time.
0 commit comments