aws-amplify / aws-amplify/amplify-cli
VS Code breakpoints ignored during "amplify mock function"
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### Before opening, please confirm:
- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
### How did you install the Amplify CLI?
npm
### If applicable, what version of Node.js are you using?
14.15.5
### Amplify CLI Version
4.45.2
### What operating system are you using?
Windows 10
### Amplify Categories
function
### Amplify Commands
Not applicable
### Describe the bug
I recently updated to the latest Amplify CLI, from version 4.17.2. Before the update, when I used `amplify function invoke [functionName]` from launch.json, I was able to set/hit break points in Visual Studio Code. Following the upgrade, when I run the debugger in VS Code using `amplify mock function [functionName]`, breakpoints are ignored and the code runs to completion. I know the code is executing correctly because I'm seeing expected output written to the console.
I'm currently making use of this workaround from cjihrig: https://github.com/aws-amplify/amplify-cli/issues/1158#issuecomment-801195432
### Expected behavior
When running `amplify mock function` in VS Code debugger, execution halts on breakpoints and allows interrogation of runtime variables, etc.
### Reproduction steps
- Create a Lambda function via Amplify CLI. Mine were created using v4.17.2, if that matters. Lambda node runtime version is nodejs12.x
- Add configuration to launch.json to mock function (example below).
- In VS Code, set a breakpoint inside Lambda's handler in index.js.
- Run the new configuration from "Run and Debug" tab in VS Code.
- Function runs to completion without hitting any breakpoints.
### Log output
```
# Put your logs below this line
```
launch.json:
```
{
"type": "node",
"request": "launch",
"name": "myFunction",
"env": {
"ENV": "mySandbox",
"REGION": "my-region-9000",
},
"program": "someFolder/amplify",
"args": [
"mock",
"function",
"myFunction"
],
"console": "integratedTerminal"
},
```
Contributor guide
Research direction
Start by reproducing the VS Code launch.json configuration that runs `amplify mock function`, then inspect the CLI entry point and the Lambda handler in index.js. Done means the debugger pauses at handler breakpoints and permits runtime-variable inspection on Windows 10 with the reported Node.js and Amplify CLI versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, node.js, typescript, vscode
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100