Is there a way to setup vscode to debug a lambda? ...
# sst
d
Is there a way to setup vscode to debug a lambda? Even if it times out in 30s (api gateway / appsync).
f
I don’t have experience with vscode peronally.. but I think @Karo and @Michael Clifford were using vscode with
sst start
to inspect the state.
m
@deini yup, setup is really simple. In VSCode's debug view you want to debug from
Run Script
and give it a
npm
script,
start
in our case
From there you can set a breakpoint and inspect the state of the stack and in-scope variables
f
Thanks for chiming in Michael ❤️
d
Nice! I'll give it a try soon, will that let me inspect only the stack or can I also breakpoint on a lambda?
k
Cliff, but we were debugging SST stuff, not a lambda.
i was checking and there's a AWS toolkit for VSCode , the only thing is that it relies on SAM i think https://docs.aws.amazon.com/toolkit-for-vscode/index.html
m
@Karo I was debugging the code that was driving the lambda
d
I can try it out 🙂 my stack is in a monorepo so I don't get the
Run Scripts
from that package, only the root package. Trying to figure out how to write a custom debugger. Once I figure it out I'll post an update 😅
k
cool, let us know
i imagine you checked the cloudwatch logs already, right?
m
@Karo / @deini recent test of the debugger paused in my Lambda code:
and a watch on the
APIGatewayProxyEventV2
event
k
that's great
m
@deini if you set the VSCode debugger to
Auto Attach: Smart
, the debugger should run when you run your command in the terminal. My debug session starts when I run
yarn run start
No configuration needed
The only thing is, the timeout will get you. The default timeout is 6 or 10 seconds. So if you pause at a breakpoint the lambda will 500 after that time
d
nice, I'll try that. I wrote a custom launcher for now and its working 😄
m
Nice, congrats! Enjoy
d
Indeed it times out super fast, maybe I can just bump the timeout in dev 🤷
m
Yea, I mentioned that to @Frank - perhaps it'd be nice to set those timeouts to 60s by default with
sst start
d
Thanks everyone! This is what I always wanted 😄 Is there any way I can contribute $ to the project?
f
Super valuable discussion.. Just opened an issue for extending Function timeout on
sst start
https://github.com/serverless-stack/serverless-stack/issues/224
@deini Appreciate the offer! Just let us know any issues u run up against.. and how we can improve the vscode integration better.. that’d be SUPER helpful!