File tree Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ public enum Lambda {
52
52
let _ = try await futureConnectionClosed. get ( )
53
53
}
54
54
55
+ logger. trace ( " Waiting for next invocation " )
55
56
let ( invocation, writer) = try await runtimeClient. nextInvocation ( )
56
57
logger[ metadataKey: " aws-request-id " ] = " \( invocation. metadata. requestID) "
57
58
@@ -87,10 +88,13 @@ public enum Lambda {
87
88
logger: logger
88
89
)
89
90
)
91
+ logger. trace ( " Handler finished processing invocation " )
90
92
} catch {
93
+ logger. trace ( " Handler failed processing invocation " , metadata: [ " Handler error " : " \( error) " ] )
91
94
try await writer. reportError ( error)
92
95
continue
93
96
}
97
+ logger. handler. metadata. removeValue ( forKey: " aws-request-id " )
94
98
}
95
99
} catch is CancellationError {
96
100
// don't allow cancellation error to propagate further
Original file line number Diff line number Diff line change @@ -17,13 +17,20 @@ import ServiceLifecycle
17
17
18
18
extension LambdaRuntime : Service {
19
19
public func run( ) async throws {
20
- await cancelWhenGracefulShutdown {
20
+ try await cancelWhenGracefulShutdown {
21
21
do {
22
22
try await self . _run ( )
23
23
} catch {
24
24
// catch top level errors that have not been handled until now
25
25
// this avoids the runtime to crash and generate a backtrace
26
26
self . logger. error ( " LambdaRuntime.run() failed with error " , metadata: [ " error " : " \( error) " ] )
27
+ if let error = error as? LambdaRuntimeError ,
28
+ error. code != . connectionToControlPlaneLost
29
+ {
30
+ // if the error is a LambdaRuntimeError but not a connection error,
31
+ // we rethrow it to preserve existing behaviour
32
+ throw error
33
+ }
27
34
}
28
35
}
29
36
}
Original file line number Diff line number Diff line change @@ -65,6 +65,13 @@ public final class LambdaRuntime<Handler>: Sendable where Handler: StreamingLamb
65
65
// catch top level errors that have not been handled until now
66
66
// this avoids the runtime to crash and generate a backtrace
67
67
self . logger. error ( " LambdaRuntime.run() failed with error " , metadata: [ " error " : " \( error) " ] )
68
+ if let error = error as? LambdaRuntimeError ,
69
+ error. code != . connectionToControlPlaneLost
70
+ {
71
+ // if the error is a LambdaRuntimeError but not a connection error,
72
+ // we rethrow it to preserve existing behaviour
73
+ throw error
74
+ }
68
75
}
69
76
}
70
77
#endif
Original file line number Diff line number Diff line change @@ -121,10 +121,8 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
121
121
} catch {
122
122
result = . failure( error)
123
123
}
124
-
125
124
await runtime. close ( )
126
125
127
- //try? await runtime.close()
128
126
return try result. get ( )
129
127
}
130
128
@@ -375,7 +373,7 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
375
373
// however, this happens when performance testing against the MockServer
376
374
// shutdown this runtime.
377
375
// The Lambda service will create a new runtime environment anyway
378
- runtimeClient. logger. trace ( " Connection to Lambda API. lost, exiting " )
376
+ runtimeClient. logger. trace ( " Connection to Lambda Service HTTP Server lost, exiting " )
379
377
runtimeClient. futureConnectionClosed = runtimeClient. eventLoop. makeFailedFuture (
380
378
LambdaRuntimeError ( code: . connectionToControlPlaneLost)
381
379
)
You can’t perform that action at this time.
0 commit comments