aws-amplify / aws-amplify/amplify-cli
While mocking, check for a running process with an open port before invoking a new process
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
I would like the ability to debug my functions locally while mocking my appsync api.
I use VSCode as my editor and Go is my preferred language.
This solution is in context to the Go language, but this implementation is agnostic to the language.
In the language runtime providers specifically where invoke is implemented, before we invoke a new process check if there is a process running. More specifically test for a debug process running. In the example of GO getting [invoked](https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-go-function-runtime-provider/src/localinvoke.ts#L85), we can check for /src/__debug_bin. Since VSCode uses [Delve](https://github.com/go-delve/delve) and when running you main.go through Delve it will compile and execute a debug bin we can test this bin is running. The next step would be to use something netstat or any tool that can get the open port so we can send the mock event.
I did try invoking the main.go with a Delve wrapper in localinvoke.ts with the remote flag then try run go remote debugger, but I had issues with synchronizing the process, attachment of VSCode debugger and the invoke call.
I have a working fork that I am using to debug my code, but only for GO and running in linux.
Contributor guide
Assessment
This issue has not been assessed yet.