Skip to content

Commit 9d5e4f3

Browse files
committed
fix error that prevented to call the server twice
1 parent f33ecaa commit 9d5e4f3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Sources/AWSLambdaRuntime/Lambda+LocalServer.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ internal struct LambdaHTTPServer {
363363
// we always accept the /invoke request and push them to the pool
364364
let requestId = "\(DispatchTime.now().uptimeNanoseconds)"
365365
logger[metadataKey: "requestId"] = "\(requestId)"
366-
logger.trace("/invoke received invocation, pushing it to the stack")
366+
logger.trace("/invoke received invocation, pushing it to the pool and wait for a lambda response")
367367
await self.invocationPool.push(LocalServerInvocation(requestId: requestId, request: body))
368368

369369
// wait for the lambda function to process the request
@@ -429,12 +429,13 @@ internal struct LambdaHTTPServer {
429429
id: requestId,
430430
status: .ok,
431431
headers: HTTPHeaders([("Content-Type", "application/json")]),
432-
body: body
432+
body: body,
433+
final: true
433434
)
434435
)
435436

436437
// tell the Lambda function we accepted the response
437-
return try await sendResponse(.init(id: requestId, status: .accepted), outbound: outbound, logger: logger)
438+
return try await sendResponse(.init(id: requestId, status: .accepted, final: true), outbound: outbound, logger: logger)
438439

439440
// :requestId/error endpoint is called by the lambda posting an error response
440441
// we accept all requestId and we do not handle the body, we just acknowledge the request
@@ -469,7 +470,7 @@ internal struct LambdaHTTPServer {
469470
) async throws {
470471
var logger = logger
471472
logger[metadataKey: "requestId"] = "\(response.requestId ?? "nil")"
472-
logger.trace("Writing response")
473+
logger.trace("Writing response for \(response.status?.code ?? 0)")
473474

474475
var headers = response.headers ?? HTTPHeaders()
475476
if let body = response.body {

0 commit comments

Comments
 (0)