Bug: No response from invoke container for helloworld function
Description:
i created a new sam app. and then immediately called sam but the lambda call timesout. I have set the timeout setting in the template.yml file to 1 minuts with the same result.
Function 'HelloWorldFunction' timed out after 3 seconds No response from invoke container for HelloWorldFunction
Steps to reproduce:
SAM init 1 - Hello world example Use the most popular runtime and package type? (Python and zip): Y Would you like to enable X-Ray tracing on the function(s) in your application? [y/N]: N Would you like to enable monitoring using CloudWatch Application Insights? N project name = Sam-Python-Hello
c:\App Dev Code\SAM_Helloworld\SAM-Python-Hello>sam local invoke HelloWorldFunction --event events/event.json Invoking app.lambda_handler (python3.9) Local image is up-to-date Using local image: public.ecr.aws/lambda/python:3.9-rapid-x86_64.
Mounting c:\App Dev Code\SAM_Helloworld\SAM-Python-Hello\hello_world as /var/task:ro,delegated inside runtime container Function 'HelloWorldFunction' timed out after 3 seconds No response from invoke container for HelloWorldFunction
Observed result:
c:\App Dev Code\SAM_Helloworld\SAM-Python-Hello>sam local invoke --debug 2023-03-15 12:34:48,092 | Config file location: c:\App Dev Code\SAM_Helloworld\SAM-Python-Hello\samconfig.toml 2023-03-15 12:34:48,093 | Loading configuration values from [default.['local', 'invoke'].parameters] (env.command_name.section) in config file at 'c:\App Dev Code\SAM_Helloworld\SAM-Python-Hello\samconfig.toml'... 2023-03-15 12:34:48,098 | Configuration values successfully loaded. 2023-03-15 12:34:48,099 | Configuration values are: {'stack_name': 'SAM-Python-Hello'} 2023-03-15 12:34:48,106 | Using SAM Template at c:\App Dev Code\SAM_Helloworld\SAM-Python-Hello\template.yaml 2023-03-15 12:34:48,125 | Using config file: samconfig.toml, config environment: default 2023-03-15 12:34:48,125 | Expand command line arguments to: 2023-03-15 12:34:48,126 | --template_file=c:\App Dev Code\SAM_Helloworld\SAM-Python-Hello\template.yaml --no_event --layer_cache_basedir=C:\Users\ingramc2\AppData\Roaming\AWS SAM\layers-pkg --container_host=localhost --container_host_interface=127.0.0.1 2023-03-15 12:34:48,126 | local invoke command is called 2023-03-15 12:34:48,130 | No Parameters detected in the template 2023-03-15 12:34:48,162 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id 2023-03-15 12:34:48,162 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id 2023-03-15 12:34:48,165 | 0 stacks found in the template 2023-03-15 12:34:48,165 | No Parameters detected in the template 2023-03-15 12:34:48,184 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id 2023-03-15 12:34:48,184 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id 2023-03-15 12:34:48,187 | 2 resources found in the stack 2023-03-15 12:34:48,187 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/' 2023-03-15 12:34:48,187 | --base-dir is not presented, adjusting uri hello_world/ relative to c:\App Dev Code\SAM_Helloworld\SAM-Python-Hello\template.yaml 2023-03-15 12:34:48,207 | Found one Lambda function with name 'HelloWorldFunction' 2023-03-15 12:34:48,208 | Invoking app.lambda_handler (python3.9) 2023-03-15 12:34:48,208 | No environment variables found for function 'HelloWorldFunction' 2023-03-15 12:34:48,208 | Loading AWS credentials from session with profile 'None' 2023-03-15 12:34:50,248 | Resolving code path. Cwd=c:\App Dev Code\SAM_Helloworld\SAM-Python-Hello, CodeUri=c:\App Dev Code\SAM_Helloworld\SAM-Python-Hello\hello_world 2023-03-15 12:34:50,248 | Resolved absolute path to code is c:\App Dev Code\SAM_Helloworld\SAM-Python-Hello\hello_world 2023-03-15 12:34:50,249 | Code c:\App Dev Code\SAM_Helloworld\SAM-Python-Hello\hello_world is not a zip/jar file 2023-03-15 12:34:54,876 | Local image is up-to-date 2023-03-15 12:34:54,905 | Using local image: public.ecr.aws/lambda/python:3.9-rapid-x86_64.
2023-03-15 12:34:54,906 | Mounting c:\App Dev Code\SAM_Helloworld\SAM-Python-Hello\hello_world as /var/task:ro,delegated inside runtime container
2023-03-15 12:34:56,102 | Starting a timer for 3 seconds for function 'HelloWorldFunction'
2023-03-15 12:34:59,113 | Function 'HelloWorldFunction' timed out after 3 seconds
2023-03-15 12:34:59,176 | Failed to get the logs from the container
Traceback (most recent call last):
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\docker\container.py", line 402, in _write_container_output
for stdout_data, stderr_data in output_itr:
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\types\daemon.py", line 32, in next
return next(self._stream)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\docker\api\client.py", line 406, in
Expected result:
SAM to locally invoke the lambda
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
# Paste the output of `sam --info` here
{ "version": "1.74.0", "system": { "python": "3.8.8", "os": "Windows-10-10.0.19041-SP0" }, "additional_dependencies": { "docker_engine": "20.10.23", "aws_cdk": "Not available", "terraform": "Not available" } }
Add --debug flag to command you are running
Thanks for raising the issue. I couldn't reproduce the issue in my Windows machine. However, from your provided logs, it seems like there's some issue from Docker. Looks like it couldn't create the lambda container for some reason. But I'm not 100% sure. Will need more investigation.
I am looking in container.py for some reason it is blowing up on wait_for_logs. I hope that helps. Thanks for confirming that it is working on your end. This a fantastic tool and I am really looking forward to using it.
I have the exact same issue, is there a fix yet?
I have the same issue on Windows 11. Docker-desktop: 4.18.0 AWS SAM CLI: 1.81
I can build my sam application with sam build --user-container, but I cannot run sam local invoke and get the same error.
{ "version": "1.81.0", "system": { "python": "3.8.8", "os": "Windows-10-10.0.22621-SP0" }, "additional_dependencies": { "docker_engine": "20.10.24", "aws_cdk": "Not available", "terraform": "Not available" } }
Consolidating issues here: https://github.com/aws/aws-sam-cli/issues/4833