Open CeccoCQ opened 2 years ago
Thanks for reporting this! Please allow us some time to start reproducing the issue and get investigate!
Getting the same issue.
I also cannot start the debugger mode with or without the --warm-containers option
sam local start-api --warm-containers LAZY -p 3001 -d 9999
Am getting the same issue. any update ?
Hello Everyone, I am having the same issue, the debugger doesn't attach and the top bar disappears.
Debug does not work at all for me. Using the built-in scaffolded hello world and executing sam local invoke -d 9999 -e events/event.json HelloWorldFunction
will successfully invoke the Lambda, but won't wait for the debugger. The hello world function just gets executed and ends.
@CeccoCQ Regarding the original issue using start-api
, I had to dive into the code a bit to find out the following:
If the template contains several functions (could be generated functions besides your original lambda, such as log retention related lambdas), a warning will be output:
Warning: you supplied debugging options but you did not specify the --debug-function option. To specify which function you want to debug, please use the --debug-function <function-name>
What's non-intuitive about this code path is that it will disable setting of the debug port rendering debugging useless in this case. If you have one function and don't specifiy --debug-function
AWS SAM will assume you meant to debug your one and only function, when using ---warm-containers
the code path will disable debugging if the function being executed isn't the one specified by --debug-function
, however the code uses different identifiers of said function to check, again rendering debugging useless, this honestly seems like a bug.
To make sure you can debug your function use --debug-function
with your current flags, but specify the function name as specified in your template, e.g: MyFunction1A65A8F
as opposed to just MyFunction
@jonkipu thanks for your answer. I've a lot of Lambda Functions and for my purposes I've to debug them concurrently, I mean more function at the time. With ---debug-function the debug will be restricted only to one function, I suppose that this is a bug or if it's a feature, it's a really strange feature (in my opinion) because if I've an API gateway at 99% I've several functions.
I agree, I was baffled by this myself, it seems that for whatever reason, when no --debug-function
is passed, debugging is disabled.
I have yet to try and change the code to see if it just works when enabling debugging and debugging multiple functions, if it does I'll update you and I guess we'll have to bring this issue into someone's attention
@CeccoCQ, played with the code a little and I think part of this is by design, since when opting to use --warm-containers
, SAM will retain the containers between invocations of each function, since it uses a different container for each function under your API, it can only expose the debug options (namely the --debug-port
) to the host OS for only one of those containers, that's why choosing --debug-function
is required, since it controls for which of your functions those debug settings are applied.
If you forego --warm-containers
SAM will create a container per function but will destroy them after that function is finished
I run into the same issue. When running either of the following:
sam local start-api --template-file template.yml --debug-port 5858 --warm-containers LAZY
sam local start-api --template-file template.yml --debug-port 5858 --warm-containers EAGER
The specific ENV variables related to debugging (NODE_OPTIONS
, NODE_PATH
etc.) weren't added to the Docker image, and the 5858 debug port wasn't exposed. I also see the warning message mentioned above:
Warning: you supplied debugging options but you did not specify the --debug-function option.
To specify which function you want to debug, please use the --debug-function <function-name>.
However when running sam local start-api --template-file template.yml --debug-port 5858
the port and the related node options are setup correctly on the Docker image. Any update on this issue?
@OrRosenblatt not sure this is so easy to fix / will be fixed soon as mentioned in my comment. I've been using the --debug-function parameter when using "--warm-containers" since then and it's fine as a workaround (at least for me)
Is there any solution to this? I'm having the same problem when executing:
sam local start-api --debug-port 5858 --debug-function MyFunction --warm-containers EAGER
I have several functions in my template. I can see one of the containers exposing port 5858 but when I click on Run And Debug, the process seems to start but stops after a few seconds.
The only thing info I see is this error under the OUTPUT
tab, when selecting Window
in the dropdown to the right:
Error: Could not connect to debug target at http://localhost:5858: Could not find any debuggable target
With this command:
sam local start-api --template-file template.yml --region eu-west-1 --debug-port 5555 --warm-containers EAGER
and this launch.json
my Visual Studio Code doesn't attach to container, I have no error or log, simply after 5 seconds the debug's topbar disappear. The terminal logs doesn't show "Debugging listening on...." when I try lo execute an HTTP request.
All works fine removing --warm-containers param.