From 6c658248960244f9212599218dddb39e6910563e Mon Sep 17 00:00:00 2001 From: Stefan Andres Charsley Date: Wed, 31 Jan 2018 17:29:53 +1300 Subject: [PATCH 1/4] Update runtime.go - Change Node 6.10 to use inspector debugging instead of legacy debugging --- runtime.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime.go b/runtime.go index bc551df2ce..f047490056 100644 --- a/runtime.go +++ b/runtime.go @@ -467,7 +467,7 @@ func (r *Runtime) getDebugEntrypoint() (overrides []string) { case runtimeName.nodejs610: overrides = []string{ "/var/lang/bin/node", - "--debug-brk=" + r.DebugPort, + "--inspect-brk=" + r.DebugPort, "--nolazy", "--max-old-space-size=1229", "--max-semi-space-size=76", From 489862a41c40fc1c8dcd797760ff052a24a88bc0 Mon Sep 17 00:00:00 2001 From: Stefan Andres Charsley Date: Wed, 31 Jan 2018 18:04:32 +1300 Subject: [PATCH 2/4] Update runtime.go - Correct commands for node 6.10 --- runtime.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime.go b/runtime.go index f047490056..8675a75c27 100644 --- a/runtime.go +++ b/runtime.go @@ -467,7 +467,8 @@ func (r *Runtime) getDebugEntrypoint() (overrides []string) { case runtimeName.nodejs610: overrides = []string{ "/var/lang/bin/node", - "--inspect-brk=" + r.DebugPort, + "--inspect=" + r.DebugPort, + "--debug-brk", "--nolazy", "--max-old-space-size=1229", "--max-semi-space-size=76", From 08b6a9f8cde1130dcf31800efc967ff43d2ac284 Mon Sep 17 00:00:00 2001 From: Stefan Andres Charsley Date: Tue, 6 Feb 2018 17:59:55 +1300 Subject: [PATCH 3/4] Update runtime.go - Don't overwrite headers --- runtime.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime.go b/runtime.go index 8675a75c27..5d290b3fda 100644 --- a/runtime.go +++ b/runtime.go @@ -600,7 +600,7 @@ func parseOutput(w http.ResponseWriter, stdoutTxt io.Reader, runtime string, wg // Set any HTTP headers requested by the proxy function if len(proxy.Headers) > 0 { for key, value := range proxy.Headers { - w.Header().Set(key, value) + w.Header().Add(key, value) } } From 9b1584fdbcc9cbbcac35db2553facb8ed04b2a81 Mon Sep 17 00:00:00 2001 From: Stefan Andres Charsley Date: Tue, 27 Feb 2018 15:53:56 +1300 Subject: [PATCH 4/4] Update README.md - Updated VSCode launch config - Added note about detaching debugger --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 65cfa319ed..0e814362cc 100644 --- a/README.md +++ b/README.md @@ -249,12 +249,14 @@ In order to setup Visual Studio Code for debugging with AWS SAM Local, use the f "port": 5858, "localRoot": "${workspaceRoot}", "remoteRoot": "/var/task", - "protocol": "legacy" + "protocol": "inspector" } ] } ``` +Note: You must detach your debugger in order for the result to be sent back to AWS SAM Local. + #### Debugging Python functions Unlike Node.JS and Java, Python requires you to enable remote debugging in your Lambda function code. If you enable debugging with `--debug-port` or `-d` for a function that uses one of the Python runtimes, SAM Local will just map through that port from your host machine through to the Lambda runtime container. You will need to enable remote debugging in your function code. To do this, use a python package such as [remote-pdb](https://pypi.python.org/pypi/remote-pdb). When configuring the host the debugger listens on in your code, make sure to use `0.0.0.0` not `127.0.0.1` to allow Docker to map through the port to your host machine.