aws / aws/aws-toolkit-vscode

SAM: debug typescript lambda locally

Open
#3,210 20 comments 12 reactions 0 assignees View on GitHub
bug language:node language:typescript sam
Dominant language
TypeScript
Stars
2k
Forks
807
Avg merge
10h 12m
Merged PRs (30d)
7

Description

## Problem
When I use esbuild to create a SAM application in typescript, I'm unable to set breakpoints in my typescript code using the direct-invoke vscode debug target.

I receive the following error:

```
Debugger attached.
Could not read source map for file:///var/task/app.js: ENOENT: no such file or directory, open 'd:\Matt\Documents\coding-projects\algoa-gtfs\generate-gtfs\app.js.map'
2023-03-04T19:23:29.832Z 35b556c5-afc6-4038-9b97-ab49edea2f37 INFO hello world
END RequestId: 35b556c5-afc6-4038-9b97-ab49edea2f37
REPORT RequestId: 35b556c5-afc6-4038-9b97-ab49edea2f37 Init Duration: 0.09 ms Duration: 105546.28 ms Billed Duration: 105547 ms Memory Size: 128 MB Max Memory Used: 128 MB
null
```

This doesn't make sense because the source map is at `D:\Matt\Documents\coding-projects\algoa-gtfs\.aws-sam\build\AlgoaGtfsFunction\app.js.map`

## Steps to reproduce the issue
1. Download this commit: https://github.com/mattsains/algoa-gtfs/tree/218f0bfb7cf33302c5bd0b7f0df7bf97aa7fd80b
1. Open in vscode
2. set a breakpoint in `app.ts`
3. Run `sam build`
4. Hit F5

## Expected behavior
The debugger should load source maps from `D:\Matt\Documents\coding-projects\algoa-gtfs\.aws-sam\build\AlgoaGtfsFunction\app.js.map` and the lambda should break at the break point set.

## System details (run the `AWS: About Toolkit` command)
OS: Windows_NT x64 10.0.22621
Visual Studio Code extension host: 1.76.0
AWS Toolkit: 1.63.0
node: 16.14.2
electron: 19.1.11

Contributor guide

Open the contributing guide

Research direction

Reproduce the direct-invoke VS Code debug flow using the linked commit, app.ts, and the generated .aws-sam/build/AlgoaGtfsFunction/app.js.map. Start by tracing how the direct-invoke target resolves the app.js source map, then verify that breakpoints in app.ts resolve and pause in the local Lambda.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript, vscode
Domain
cloud, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.