DEV Community

Discussion on: AWS CDK - aws-lambda-nodejs Module (updated)

Collapse
 
zakos profile image
Zakos • Edited

Hey , I managed changed to NodejsFunction and my function reduce from 50MB~ to 400KB~ , my only problem is debugging , I did managed to debug my lambda using Function , but with NodejsFunction I can't make it work , the function does run , but debugging doesn't stop on breakpoint , did you mange to debug it ? there is sourceMaps: true property for NodejsFunction , tried played with launch.json configurations ,did something like localRoot": "${workspaceRoot}/.cdk.staging/asset-bundle-G0UqOf", ( where index.map.js is) , but nothing happens (when localRoot can't find index.map.js) it shows message in "debug" tab

UPDATE
I manged to debug ,
but i need to put a breakpoint inside /.cdk.staging/asset-bundle-G0UqOf/index.js which is HUGE LONG file.... not so user friendly

Collapse
 
elthrasher profile image
Matt Morgan

Yeah, I wouldn't expect it to be very easy to put break points in bundled code. Are you running your function with SAM or something like that or just running it locally with node (not as Lamba)? If the latter, I suggest you just use something like ts-node and don't bundle it.

That's also a great use case for TDD where you write a test that you think will interact with your problematic code and shake it out that way. Sometimes TDD = test-driven debugging ;)

Collapse
 
zakos profile image
Zakos

yea with SAM ,
sam local invoke lambdaHandler36FF0F39 -d 9999 -e events/1.json ,
well it's a CDK project I play with , I except as long as we move forward to future .... that cdk-serverless will be easier to develop and debug... isn't it all the idea ? :)