https://serverless-stack.com/ logo
#sst
Title
# sst
d

deini

03/10/2021, 11:33 PM
Is there a way to setup vscode to debug a lambda? Even if it times out in 30s (api gateway / appsync).
f

Frank

03/10/2021, 11:35 PM
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

Michael Clifford

03/10/2021, 11:39 PM
@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

Frank

03/10/2021, 11:40 PM
Thanks for chiming in Michael ❤️
d

deini

03/10/2021, 11:47 PM
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

Karo

03/10/2021, 11:48 PM
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

Michael Clifford

03/10/2021, 11:50 PM
@Karo I was debugging the code that was driving the lambda
d

deini

03/10/2021, 11:57 PM
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

Karo

03/10/2021, 11:59 PM
cool, let us know
i imagine you checked the cloudwatch logs already, right?
m

Michael Clifford

03/11/2021, 12:00 AM
@Karo / @deini recent test of the debugger paused in my Lambda code:
and a watch on the
APIGatewayProxyEventV2
event
k

Karo

03/11/2021, 12:03 AM
that's great
m

Michael Clifford

03/11/2021, 12:03 AM
@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

deini

03/11/2021, 12:06 AM
nice, I'll try that. I wrote a custom launcher for now and its working 😄
m

Michael Clifford

03/11/2021, 12:07 AM
Nice, congrats! Enjoy
d

deini

03/11/2021, 12:07 AM
Indeed it times out super fast, maybe I can just bump the timeout in dev 🤷
m

Michael Clifford

03/11/2021, 12:08 AM
Yea, I mentioned that to @Frank - perhaps it'd be nice to set those timeouts to 60s by default with
sst start
d

deini

03/11/2021, 12:08 AM
Thanks everyone! This is what I always wanted 😄 Is there any way I can contribute $ to the project?
f

Frank

03/11/2021, 1:02 AM
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!
2 Views