Skip to content

Commit f232ca9

Browse files
committed
don't call postInvocationResponse() / postInvocationError() from the handler callback
1 parent b9a87c2 commit f232ca9

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Sources/AWSLambdaSwift/Runtime.swift

+10-8
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,20 @@ public class Runtime {
126126
let dispatchGroup = DispatchGroup()
127127
dispatchGroup.enter()
128128

129-
handler.apply(inputData: inputData, context: context) { handlerResult in
130-
switch handlerResult {
131-
case .success(let outputData):
132-
self.postInvocationResponse(for: context.awsRequestId, httpBody: outputData)
133-
case .failure(let error):
134-
self.postInvocationError(for: context.awsRequestId, error: error)
135-
}
136-
129+
var handlerResult: HandlerResult?
130+
handler.apply(inputData: inputData, context: context) { result in
131+
handlerResult = result
137132
dispatchGroup.leave()
138133
}
139134

140135
dispatchGroup.wait()
136+
137+
switch handlerResult! {
138+
case .success(let outputData):
139+
postInvocationResponse(for: context.awsRequestId, httpBody: outputData)
140+
case .failure(let error):
141+
postInvocationError(for: context.awsRequestId, error: error)
142+
}
141143
}
142144
}
143145
}

0 commit comments

Comments
 (0)