-
Notifications
You must be signed in to change notification settings - Fork 118
Description
Expected behavior
When using the LocalServer
for testing locally a Streaming Lambda function, we expect the user to invoke the Lambda function multiple times without having to restart the server between invocations.
This is the behavior of the server with non-streaming Lambda function.
Actual behavior
When invoking the local test server (POST /invoke
) with a streaming Lambda function, the Local Lambda function is correctly run and returns the expected value.
However, the local server never handles the subsequent GET /next
issued by the lambda runtime client.
This makes impossible to invoke the function twice on the local test server.
Steps to reproduce
cd Examples/Streaming
swift run
From another terminal
curl -v --output test1.txt --header "Content-Type: application/json" --data '"1111"' http://127.0.0.1:7000/invoke
Wait three seconds and you will see result in test1.txt
$ cat test1.txt
{"headers":{"Content-Type":"text/plain","x-my-custom-header":"streaming-example"},"statusCode":418}Number: 1
Number: 2
Number: 3
Streaming complete!
Now invoke the function a second time
curl -v --output test2.txt --header "Content-Type: application/json" --data '"2222"' http://127.0.0.1:7000/invoke
The call blocks and never returns.
On the server trace, we can see
2025-10-16T13:34:34+0200 trace LambdaRuntime : URI=POST /invoke requestId=615386897861416 response requestId=615386897861416 [AWSLambdaRuntime] /invoke returning
2025-10-16T13:34:34+0200 trace LambdaRuntime : [AWSLambdaRuntime] Done handling the connection
2025-10-16T13:34:40+0200 trace LambdaRuntime : [AWSLambdaRuntime] Handling a new connection
2025-10-16T13:34:40+0200 trace LambdaRuntime : Body="1111" URI=POST /invoke [AWSLambdaRuntime] Processing request
2025-10-16T13:34:40+0200 trace LambdaRuntime : URI=POST /invoke requestId=615396149012541 [AWSLambdaRuntime] /invoke received invocation, pushing it to the pool and wait for a lambda response
The runtime never sends the next GET /next request
Here is the trace from a non-streaming function for comparison:
2025-10-16T13:40:57+0200 trace LambdaRuntime: aws-request-id=615770142842041 [AWSLambdaRuntime] Handler finished processing invocation
2025-10-16T13:40:57+0200 trace LambdaRuntime: [AWSLambdaRuntime] Waiting for next invocation
2025-10-16T13:40:57+0200 trace LambdaRuntime: URI=GET /2018-06-01/runtime/invocation/next [AWSLambdaRuntime] Processing request
2025-10-16T13:40:57+0200 trace LambdaRuntime: URI=GET /2018-06-01/runtime/invocation/next [AWSLambdaRuntime] /next waiting for /invoke
2025-10-16T13:40:57+0200 trace LambdaRuntime: [AWSLambdaRuntime] Done handling the connection
If possible, minimal yet complete reproducer code (or URL to code)
No response
What version of this project (swift-aws-lambda-runtime
) are you using?
2.2.0
Swift version
n/a
Amazon Linux 2 docker image version
n/a