Skip to content

Commit 6e01c6e

Browse files
committed
force exit() when we loose connection to Lambda service
1 parent 2020d6b commit 6e01c6e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/AWSLambdaRuntime/LambdaRuntimeClient.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
330330
try channel.pipeline.syncOperations.addHTTPClientHandlers()
331331
// Lambda quotas... An invocation payload is maximal 6MB in size:
332332
// https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html
333+
// TODO: should we enforce this here ? What about streaming functions that
334+
// support up to 20Mb responses ?
333335
try channel.pipeline.syncOperations.addHandler(
334336
NIOHTTPClientResponseAggregator(maxContentLength: 6 * 1024 * 1024)
335337
)
@@ -364,6 +366,14 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
364366
channel.closeFuture.whenComplete { result in
365367
self.assumeIsolated { runtimeClient in
366368
runtimeClient.channelClosed(channel)
369+
370+
// at this stage, we lost the connection to the Lambda Service,
371+
// this is very unlikely to happen when running in a lambda function deployed in the cloud
372+
// however, this happens when performance testing against the MockServer
373+
// shutdown this runtime.
374+
// The Lambda service will create a new runtime environment anyway
375+
runtimeClient.logger.trace("Connection to Lambda API lost, exiting")
376+
exit(-1)
367377
}
368378
}
369379

0 commit comments

Comments
 (0)