Open MrZakos opened 3 years ago
@jogold copy
Adding the following to NodejsFunctionProps helps here (maps lines in stack traces back to source at least)
environment: {
NODE_OPTIONS: "--enable-source-maps",
},
bundling: {
sourceMap: true, // include source map, defaults to false
},
This one's driving me crazy. I'm doing all sorts of work-arounds to deal with the asset directory changing but then the result is ultimately that only the asset directory can be debugged using breakpoints.
@MrZakos @eikeon have you found a way to allow a debugger to be used on the original files (prior to the bundling)?
I'll keep digging around and create a blog post once complete, it's all been very frustrating.
@lprhodes you right , it drives you crazy, that's why I don't debug that way my current workaround : I created a test.ts file to run locally (node.js runtime) which runs local function to test whatever I need. it requires extra work to create a "service" which know to run other "services/functions"
//test.ts
(async () => {
try {
// await foo()
} catch (error) {
console.log("error >>", error)
}
})()
//launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Tester",
"program": "${workspaceFolder}/lambda/tester/test.ts",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
{
"name": "Attach to SAM CLI",
"type": "node",
"request": "attach",
"address": "localhost",
"port": 9999,
"remoteRoot": "/var/task",
"localRoot": "${workspaceRoot}/.cdk.staging/asset-bundle-VFH6MU",
"protocol": "inspector",
"stopOnEntry": false
}
]
}
@MrZakos @lprhodes Using lambda-local (https://github.com/ashiina/lambda-local) has really helped in our development. Worth checking out.
Curious if this feature request has been prioritized, or if there is another workaround besides creating a test that invokes the lambda or manually pasting the generated asset directory name cdk.out/asset.YYY..
into the launch config after running synth
? When running synth --no-staging
the template Metadata does not contain a reference to the source code like it does when the lambda is created via @aws-cdk/aws-lambda
following
Linking related per @madeline-k: https://github.com/aws/aws-cdk/issues/9189
@aws-lambda-nodejs
how to debug locally my lambda with @aws-cdk/aws-lambda-nodejs ? with @aws-cdk/aws-lambda I managed to debug successfully , but this is a similiar but diffrent creature because it's bundle it to a folder something like cdk.staging/asset-bundle-G0UqOf (where index.js and index.map.js are) if some 1 managed to do it - please share you findings (include launch.json)
UPDATE I managed 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